From da5d8fa45083aca070c8dd4d898e6dd848cf86cb Mon Sep 17 00:00:00 2001 From: Julien Moutinho Date: Sun, 13 Apr 2025 11:47:12 +0200 Subject: [PATCH] add comments --- flake.lock | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++- flake.nix | 56 +++++++++++++++++++++++++++++++++++--- 2 files changed, 131 insertions(+), 4 deletions(-) diff --git a/flake.lock b/flake.lock index b424b9c..1c798f0 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,48 @@ { "nodes": { + "android-nixpkgs": { + "inputs": { + "devshell": "devshell", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1744057253, + "narHash": "sha256-cXV1MuZiFpee239JVYfzhxa8FYv6Qm3upmWdo4N2ms8=", + "owner": "tadfisher", + "repo": "android-nixpkgs", + "rev": "b6b6602b927e15f4851b119b2c726768f02e2527", + "type": "github" + }, + "original": { + "owner": "tadfisher", + "repo": "android-nixpkgs", + "type": "github" + } + }, + "devshell": { + "inputs": { + "nixpkgs": [ + "android-nixpkgs", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1741473158, + "narHash": "sha256-kWNaq6wQUbUMlPgw8Y+9/9wP0F8SHkjy24/mN3UAppg=", + "owner": "numtide", + "repo": "devshell", + "rev": "7c9e793ebe66bcba8292989a68c0419b737a22a0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -18,6 +61,24 @@ "type": "github" } }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1743938762, @@ -36,7 +97,8 @@ }, "root": { "inputs": { - "flake-utils": "flake-utils", + "android-nixpkgs": "android-nixpkgs", + "flake-utils": "flake-utils_2", "nixpkgs": "nixpkgs" } }, @@ -54,6 +116,21 @@ "repo": "default", "type": "github" } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 30f6389..12f3617 100644 --- a/flake.nix +++ b/flake.nix @@ -1,7 +1,34 @@ { + # UsageNote: to run the emulator + # nix -L run .#emulate-android-x86_64 + # + # UsageNote: to run load gradle into $PATH + # nix -L develop description = "Nix flake to develop for Android"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; inputs.flake-utils.url = "github:numtide/flake-utils"; + + # ExplanationNote: an alternative way to install Android tools, + # not sure if it's better than nixpkgs' machinery at anything. + # Just here for reference. + inputs.android-nixpkgs = { + url = "github:tadfisher/android-nixpkgs"; + + # ExplanationNote: + # The main branch follows the "canary" channel of the Android SDK + # repository. Use another android-nixpkgs branch to explicitly + # track an SDK release channel. + # + # url = "github:tadfisher/android-nixpkgs/stable"; + # url = "github:tadfisher/android-nixpkgs/beta"; + # url = "github:tadfisher/android-nixpkgs/preview"; + # url = "github:tadfisher/android-nixpkgs/canary"; + + # ExplanationNote: replace the "nixpkgs" input for the "android-nixpkgs" flake. + inputs.nixpkgs.follows = "nixpkgs"; + }; + outputs = inputs: let @@ -80,6 +107,7 @@ app = null; deviceName = "device"; package = ""; + # ToDo: set this when the emulator will be working # for emulate-android-armeabi-v7a # or emulate-android-arm64-v8a @@ -111,13 +139,34 @@ { packages = rec { default = emulate-android-x86_64; + emulate-android-x86_64 = androidEmulateApp { abiVersion = "x86_64"; }; - # FixMe: PANIC: Avd's CPU Architecture 'arm64' is not supported by the QEMU2 emulator on x86_64 host. + + # FailureNote: PANIC: Avd's CPU Architecture 'arm64' is not supported by the QEMU2 emulator on x86_64 host. + # ExplanationNote: https://developer.android.com/studio/releases/emulator#support_for_arm_binaries_on_android_9_and_11_system_images + # If you were previously unable to use the Android Emulator because + # your app depended on ARM binaries, you can now use the Android 9 + # x86 system image or any Android 11 system image to run your app – + # it is no longer necessary to download a specific system image to + # run ARM binaries. These Android 9 and Android 11 system images + # support ARM by default and provide dramatically improved + # performance when compared to those with full ARM emulation. emulate-android-arm64-v8a = androidEmulateApp { abiVersion = "arm64-v8a"; }; - # FixMe: PANIC: CPU Architecture 'arm' is not supported by the QEMU2 emulator, (the classic engine is deprecated!) + + # FailureNote: PANIC: CPU Architecture 'arm' is not supported by the QEMU2 emulator, (the classic engine is deprecated!) # Note: only androidPlatformVersion <= 25 still provide images for this ABI # See nixpkgs/pkgs/development/mobile/androidenv/repo.json emulate-android-armeabi-v7a = androidEmulateApp { abiVersion = "armeabi-v7a"; }; + + android-sdk = inputs.android-nixpkgs.sdk ( + sdkPkgs: with sdkPkgs; [ + cmdline-tools-latest + build-tools-34-0-0 + platform-tools + platforms-android-34 + emulator + ] + ); }; devShell = @@ -139,7 +188,8 @@ export ANDROID_NDK_ROOT="${androidComposition.androidsdk}/libexec/android-sdk/ndk-bundle" export PATH="$(echo "$ANDROID_SDK_ROOT/cmake/${androidCmakeVersion}".*/bin):$PATH" - # Use the same androidBuildToolsVersion and a statically linked aapt2 + # Use the same androidBuildToolsVersion + # and a statically linked aapt2 to workaround a dynamic linking failure. export GRADLE_OPTS="-Dorg.gradle.project.android.aapt2FromMavenOverride=$ANDROID_SDK_ROOT/build-tools/${androidBuildToolsVersion}/aapt2"; ''; }; -- 2.47.2