Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2022-06-09 17:56:44 +02:00
parent bf1fc8529f
commit 878f0dab01
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4
3 changed files with 85 additions and 0 deletions

30
nix/androidsdk.nix Normal file
View File

@ -0,0 +1,30 @@
{ stdenv, androidenv }:
# The "android-sdk-license" license is accepted
# by setting android_sdk.accept_license = true.
androidenv.composeAndroidPackages {
toolsVersion = "26.1.1";
platformToolsVersion = "31.0.3";
buildToolsVersions = [ "31.0.0" ];
platformVersions = [ "30" ];
cmakeVersions = [ "3.18.1" ];
ndkVersion = "22.1.7171670";
includeNDK = true;
includeExtras = [
"extras;android;m2repository"
"extras;google;m2repository"
];
}
# This derivation simply symlinks some stuff to get
# shorter paths as libexec/android-sdk is quite the mouthful.
# With this you can just do `androidPkgs.sdk` and `androidPkgs.ndk`.
#stdenv.mkDerivation {
# name = "${compose.androidsdk.name}-mod";
# phases = [ "symlinkPhase" ];
# outputs = [ "out" "sdk" "ndk" ];
# symlinkPhase = ''
# ln -s ${compose.androidsdk} $out
# ln -s ${compose.androidsdk}/libexec/android-sdk $sdk
# ln -s ${compose.androidsdk}/libexec/android-sdk/ndk-bundle $ndk
# '';
#}

5
nix/default.nix Normal file
View File

@ -0,0 +1,5 @@
{ pkgs ? import ../../nixpkgs {
config.android_sdk.accept_license = true;
} }:
pkgs.callPackage ./mobile.nix { }

50
nix/mobile.nix Normal file
View File

@ -0,0 +1,50 @@
{ lib, pkgs, callPackage, buildGoModule }:
let
androidPkgs = pkgs.androidenv.composeAndroidPackages {
includeNDK = true;
ndkVersion = "22.1.7171670";
};
androidSdk = androidPkgs.androidsdk;
gomobile = pkgs.gomobile.override { inherit androidPkgs; };
in buildGoModule {
pname = "go-waku";
version = "devel";
vendorSha256 = "sha256-+W5PnVmD4oPh3a8Ik9Xn3inCI8shqEsdlkG/d6PQntk=";
GIT_COMMIT = "TODO";
doCheck = false;
src = ./..;
extraSrcPaths = [ gomobile ];
nativeBuildInputs = [ gomobile pkgs.openjdk8 ];
# We can't symlink gomobile src in vendor created by buildGoModule.
proxyVendor = true;
ANDROID_HOME = "${androidSdk}/libexec/android-sdk";
ANDROID_NDK_ROOT = "${androidSdk}/libexec/android-sdk/ndk-bundle";
ANDROID_NDK_HOME = "${androidSdk}/libexec/android-sdk/ndk-bundle";
#GOMOBILE = pkgs.gomobile;
#GOHOSTARCH = "amd64";
#GO111MODULE = "off";
buildPhase = ''
gomobile bind -x \
-target=android/arm64 \
-androidapi=23 \
-ldflags="-s -w" \
-o ./build/lib/Gowaku.xcframework \
./mobile
'';
#buildPhase = ''
# echo $ANDROID_HOME
# gomobile bind -x \
# -target=ios \
# -iosversion=8.0 \
# -ldflags="-s -w" \
# -o ./build/lib/Gowaku.xcframework \
# ./mobile
#'';
}