-
Notifications
You must be signed in to change notification settings - Fork 203
Expand file tree
/
Copy pathflake.nix
More file actions
74 lines (66 loc) · 2.25 KB
/
flake.nix
File metadata and controls
74 lines (66 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
{
description = "Slim Android SDK tools for Devbox via flakes";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs =
{ self, nixpkgs }:
let
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
versionData = builtins.fromJSON (builtins.readFile ./platform-versions.json);
getVar =
name: default:
if builtins.hasAttr name versionData then toString (builtins.getAttr name versionData) else default;
androidSdkConfig = {
platformVersions = [
(getVar "PLATFORM_ANDROID_MIN_API" "21")
(getVar "PLATFORM_ANDROID_MAX_API" "33")
];
buildToolsVersion = getVar "PLATFORM_ANDROID_BUILD_TOOLS_VERSION" "30.0.3";
cmdLineToolsVersion = getVar "PLATFORM_ANDROID_CMDLINE_TOOLS_VERSION" "19.0";
systemImageTypes = [ (getVar "PLATFORM_ANDROID_SYSTEM_IMAGE_TAG" "google_apis") ];
};
forAllSystems =
f:
builtins.listToAttrs (
map (system: {
name = system;
value = f system;
}) systems
);
in
{
packages = forAllSystems (
system:
let
pkgs = import nixpkgs {
inherit system;
config = {
allowUnfree = true;
android_sdk.accept_license = true;
};
};
abiVersions = if builtins.match "aarch64-.*" system != null then [ "arm64-v8a" ] else [ "x86_64" ];
androidPkgs = pkgs.androidenv.composeAndroidPackages {
# Keep API 21 images for the AVD and add API 33 for React Native builds.
platformVersions = androidSdkConfig.platformVersions;
buildToolsVersions = [ androidSdkConfig.buildToolsVersion ];
cmdLineToolsVersion = androidSdkConfig.cmdLineToolsVersion;
includeEmulator = true;
includeSystemImages = true;
includeNDK = false;
abiVersions = abiVersions;
systemImageTypes = androidSdkConfig.systemImageTypes;
};
in
{
android-sdk = androidPkgs.androidsdk;
default = androidPkgs.androidsdk;
}
);
androidSdkConfig = androidSdkConfig;
};
}