From 36fc4d944829721d0a16b14512595c9c0af4a257 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone <exarkun@twistedmatrix.com> Date: Tue, 8 Nov 2022 16:52:08 -0500 Subject: [PATCH] Get `p4a apk ...` doing _something_ apart from trivially crashing --- android.nix | 25 +++++++++++++++++++++++++ flake.lock | 7 ++++--- flake.nix | 47 ++++++++++++++++++++++++++++++++--------------- 3 files changed, 61 insertions(+), 18 deletions(-) create mode 100644 android.nix diff --git a/android.nix b/android.nix new file mode 100644 index 0000000..30309a0 --- /dev/null +++ b/android.nix @@ -0,0 +1,25 @@ +{ androidenv, cmakeVersion }: +let + androidComposition = androidenv.composeAndroidPackages { + toolsVersion = "26.1.1"; + # platformToolsVersion = "30.0.5"; + buildToolsVersions = [ "30.0.3" ]; + includeEmulator = false; + emulatorVersion = "30.3.4"; + platformVersions = [ "27" "28" "29" "30" ]; + includeSources = false; + includeSystemImages = false; + systemImageTypes = [ "google_apis_playstore" ]; + abiVersions = [ "armeabi-v7a" "arm64-v8a" ]; + cmakeVersions = [ cmakeVersion ]; + includeNDK = true; + # Check out pkgs/development/mobile/androidenv/repo.json + ndkVersions = [ "23.0.7123448-rc1" "22.0.7026061" ]; + useGoogleAPIs = false; + useGoogleTVAddOns = false; + includeExtras = [ + "extras;google;gcm" + ]; + }; +in +androidComposition diff --git a/flake.lock b/flake.lock index 439020b..0a5cd5b 100644 --- a/flake.lock +++ b/flake.lock @@ -43,15 +43,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1667933212, - "narHash": "sha256-Iu5yhT4nr+IsGPnk61eTKLmffPRL0dwJpWBlIFnAXvY=", + "lastModified": 1667821506, + "narHash": "sha256-u4HKBBfTOPpFsGnM7sjS0+F67Hmf2or3uHKNVxXZtiM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "0ab419f97ad748a3150183d3e0706e949924de7a", + "rev": "ebf65554b18ee053311f43e5faa5a3f36626c52e", "type": "github" }, "original": { "owner": "NixOS", + "ref": "nixos-22.05", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index 2bdd071..229981c 100644 --- a/flake.nix +++ b/flake.nix @@ -1,23 +1,23 @@ { description = "The PrivateStorage Mobile application"; inputs = { + nixpkgs = { + url = "github:NixOS/nixpkgs?ref=nixos-22.05"; + }; + flake-utils.url = "github:numtide/flake-utils"; + pypi-deps-db = { + flake = false; + url = "github:DavHau/pypi-deps-db"; + }; mach-nix-flake = { flake = true; url = "github:DavHau/mach-nix"; inputs = { - pypi-deps-db.follows = "pypi-deps-db"; nixpkgs.follows = "nixpkgs"; flake-utils.follows = "flake-utils"; + pypi-deps-db.follows = "pypi-deps-db"; }; }; - nixpkgs = { - url = "github:NixOS/nixpkgs"; - }; - flake-utils.url = "github:numtide/flake-utils"; - pypi-deps-db = { - flake = false; - url = "github:DavHau/pypi-deps-db"; - }; }; outputs = { self, nixpkgs, flake-utils, mach-nix-flake, ... }: flake-utils.lib.eachSystem [ "x86_64-linux" ] (system: let @@ -25,7 +25,10 @@ mach-nix = mach-nix-flake.lib.${system}; pkgs = import nixpkgs { inherit system; - config = { allowUnfree = true; }; + config = { + allowUnfree = true; + android_sdk.accept_license = true; + }; }; lib = pkgs.lib; @@ -40,18 +43,32 @@ ''; }; + cmakeVersion = "3.10.2"; + + # Also includes ndk + androidComposition = pkgs.callPackage ./android.nix { inherit cmakeVersion; }; + in { - devShells.default = pkgs.mkShell { + # https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/android.section.md + # is a good reference for this stuff. + devShells.default = pkgs.mkShell rec { name = "ps-mobile"; version = "2022.10.21"; + # The docs talk about ANDROID_SDK_ROOT but apparently it has been + # renamed yet again. + ANDROIDSDK = "${androidComposition.androidsdk}/libexec/android-sdk"; + ANDROIDNDK = "${ANDROIDSDK}/ndk-bundle"; + + shellHook = '' + export PATH="$(echo "$ANDROIDSDK/cmake/${cmakeVersion}".*/bin):$PATH" + ''; + + buildInputs = with pkgs; [ android-studio - android-tools - androidndkPkgs_23b.binaries - androidndkPkgs_23b.binutils - androidndkPkgs_23b.libraries kivy-env + openjdk8 ]; }; }); -- GitLab