-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathflake.nix
97 lines (80 loc) · 2.91 KB
/
flake.nix
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
{
inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixpkgs-unstable;
android-nixpkgs.url = github:tadfisher/android-nixpkgs;
utils.url = github:numtide/flake-utils;
};
outputs = { self, nixpkgs, android-nixpkgs, utils }:
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
config.android_sdk.accept_license = true;
config.allowUnfree = true;
};
java = pkgs.jdk11;
platformsAndroidVersion = "33";
ndkVersion = "25.1.8937393";
buildToolsVersion = "33.0.0";
platformToolsVersion = "33.0.3";
cmakeVersion = "3.10.2.4988404";
toSdkVersion = v: builtins.replaceStrings [ "." ] [ "-" ] v;
android-sdk = android-nixpkgs.sdk."${system}" (sdkPkgs: [
sdkPkgs.cmdline-tools-latest
sdkPkgs.platform-tools
sdkPkgs."build-tools-${toSdkVersion buildToolsVersion}"
sdkPkgs."platforms-android-${toSdkVersion platformsAndroidVersion}"
sdkPkgs."ndk-${toSdkVersion ndkVersion}"
sdkPkgs."cmake-${toSdkVersion cmakeVersion}"
]);
sdkDir = "${android-sdk}/share/android-sdk";
# Build inputs
requiredPrograms = with pkgs; [
# androidComposition.androidsdk
android-sdk
java
cmake
pkg-config
autoreconfHook
];
# Compiletime/Runtime deps
requiredLibs = with pkgs; [
];
# IDE/shell dependencies
developPrograms = with pkgs; [
android-studio
];
projectName = "libgdx-oboe";
in
rec {
# `nix build`
packages."${projectName}" = pkgs.androidenv.buildApp {
pname = projectName;
version = "0.3.0";
src = self;
release = true;
nativeBuildInputs = requiredPrograms;
buildInputs = requiredLibs;
platformVersions = [ "24" ];
includeNDK = true;
};
defaultPackage = packages."${projectName}";
# `nix develop`
devShell = pkgs.mkShell rec {
nativeBuildInputs = developPrograms ++ requiredPrograms;
buildInputs = requiredLibs;
ANDROID_SDK_ROOT = "${sdkDir}";
ANDROID_NDK_ROOT = "${ANDROID_SDK_ROOT}/ndk/${ndkVersion}";
NDK_VERSION = ndkVersion;
NDK_DIR = "${ANDROID_NDK_ROOT}";
GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${ANDROID_SDK_ROOT}/build-tools/${buildToolsVersion}/aapt2";
JAVA_HOME = "${java.home}";
shellHook = ''
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.lib.makeLibraryPath buildInputs}";
export PATH="$ANDROID_SDK_ROOT/cmake/${cmakeVersion}"/bin:$PATH"
echo "// Auto-generated by flake.nix\nsdk.dir=$ANDROID_SDK_ROOT" > local.properties
chmod -w local.properties
'';
};
});
}