61 lines
2.5 KiB
Nix
61 lines
2.5 KiB
Nix
|
|
{
|
||
|
|
description = "photogallery Android uploader dev shell";
|
||
|
|
|
||
|
|
inputs = {
|
||
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||
|
|
flake-utils.url = "github:numtide/flake-utils";
|
||
|
|
|
||
|
|
# Reproducible Android SDK across NixOS + macOS without the nixpkgs
|
||
|
|
# androidenv read-only-SDK-root quirks.
|
||
|
|
android-nixpkgs = {
|
||
|
|
url = "github:tadfisher/android-nixpkgs/stable";
|
||
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
||
|
|
};
|
||
|
|
};
|
||
|
|
|
||
|
|
outputs = { self, nixpkgs, flake-utils, android-nixpkgs }:
|
||
|
|
flake-utils.lib.eachDefaultSystem (system:
|
||
|
|
let
|
||
|
|
pkgs = import nixpkgs {
|
||
|
|
inherit system;
|
||
|
|
config.allowUnfree = true; # Android SDK is unfree
|
||
|
|
};
|
||
|
|
|
||
|
|
buildToolsVersion = "36.0.0";
|
||
|
|
|
||
|
|
# SDK components for the Compose app. Pinned to the exact versions
|
||
|
|
# the Gradle config requests — adding extras only inflates the
|
||
|
|
# closure. When AGP bumps any of these, the build error names the
|
||
|
|
# exact missing version: look it up in `android-nixpkgs` and replace
|
||
|
|
# the line. No NDK or CMake: there is no native code in this app.
|
||
|
|
androidSdk = android-nixpkgs.sdk.${system} (sdkPkgs: with sdkPkgs; [
|
||
|
|
cmdline-tools-latest # sdkmanager, avdmanager
|
||
|
|
platform-tools # adb, for sideloading to the phone
|
||
|
|
platforms-android-36 # compileSdk / targetSdk
|
||
|
|
build-tools-36-0-0 # aapt2, d8, zipalign
|
||
|
|
build-tools-35-0-0 # AGP 8.x resolves this one too, and the
|
||
|
|
# nix store is read-only so it cannot
|
||
|
|
# download it itself
|
||
|
|
]);
|
||
|
|
in {
|
||
|
|
devShells.default = pkgs.mkShell {
|
||
|
|
packages = [
|
||
|
|
pkgs.jdk17 # AGP 8.x toolchain
|
||
|
|
pkgs.gradle # bootstraps ./gradlew, then the wrapper takes over
|
||
|
|
androidSdk
|
||
|
|
];
|
||
|
|
|
||
|
|
shellHook = ''
|
||
|
|
export ANDROID_HOME="${androidSdk}/share/android-sdk"
|
||
|
|
export ANDROID_SDK_ROOT="$ANDROID_HOME"
|
||
|
|
export JAVA_HOME="${pkgs.jdk17.home}"
|
||
|
|
|
||
|
|
# AGP downloads aapt2 from Maven by default. The Maven binary is
|
||
|
|
# generic-linux ELF and won't run on NixOS. Force Gradle to use the
|
||
|
|
# patchelfed aapt2 shipped in our pinned build-tools instead.
|
||
|
|
export GRADLE_OPTS="-Dorg.gradle.project.android.aapt2FromMavenOverride=$ANDROID_HOME/build-tools/${buildToolsVersion}/aapt2"
|
||
|
|
'';
|
||
|
|
};
|
||
|
|
});
|
||
|
|
}
|