diff --git a/nix/default.nix b/nix/default.nix index 35fb95d6..8e284fbc 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -1,5 +1,7 @@ +#{ pkgs ? import { { pkgs ? import ../../nixpkgs { config.android_sdk.accept_license = true; } }: -pkgs.callPackage ./mobile.nix { } +#pkgs.callPackage ./mobile_pkg.nix { } +pkgs.callPackage ./mobile_mod.nix { } diff --git a/nix/mobile_mod.nix b/nix/mobile_mod.nix new file mode 100644 index 00000000..51bda0c8 --- /dev/null +++ b/nix/mobile_mod.nix @@ -0,0 +1,60 @@ +{ lib, pkgs, callPackage, buildGoModule }: + +let + androidPkgs = pkgs.androidenv.composeAndroidPackages { + platformVersions = [ "23" ]; + ndkVersion = "22.1.7171670"; + includeNDK = true; + }; + androidSdk = androidPkgs.androidsdk; + #gomobile = pkgs.gomobile.override { inherit androidPkgs; }; +in buildGoModule { + pname = "go-waku"; + version = "devel"; + vendorSha256 = "sha256-+U8mlEK7HvCtssI8VDqxGaOvi+IU0+cr4isZLl9sB4o="; + deleteVendor = true; + doCheck = false; + + src = ./..; + + nativeBuildInputs = [ pkgs.gomobile pkgs.openjdk8 ]; + + # We can't symlink gomobile src in vendor created by buildGoModule. + proxyVendor = true; + + ANDROID_HOME = "${androidSdk}/libexec/android-sdk"; + + # Correct GOPATH necessary to avoid error: + # `no exported names in the package "_/build/go-waku/mobile"` + preBuild = '' + export GO111MODULE=off + mkdir -p /build/go/src/github.com/status-im + mv /build/go-waku /build/go/src/github.com/status-im/ + cd /build/go/src/github.com/status-im/go-waku + ''; + + buildPhase = '' + runHook preBuild + gomobile bind -x \ + -target=android/arm64 \ + -androidapi=23 \ + -ldflags="-s -w" \ + -o go-waku.aar \ + ./mobile + ''; + + installPhase = '' + mkdir -p $out + mv go-waku.aar $out/ + ''; + + #buildPhase = '' + # echo $ANDROID_HOME + # gomobile bind -x \ + # -target=ios \ + # -iosversion=8.0 \ + # -ldflags="-s -w" \ + # -o ./build/lib/go-waku.xcframework \ + # ./mobile + #''; +} diff --git a/nix/mobile.nix b/nix/mobile_pkg.nix similarity index 59% rename from nix/mobile.nix rename to nix/mobile_pkg.nix index 518d5cb8..e924bada 100644 --- a/nix/mobile.nix +++ b/nix/mobile_pkg.nix @@ -1,44 +1,41 @@ -{ lib, pkgs, callPackage, buildGoModule }: +{ lib, pkgs, callPackage, buildGoModule, buildGoPackage }: let androidPkgs = pkgs.androidenv.composeAndroidPackages { - includeNDK = true; + toolsVersion = "26.1.1"; + platformToolsVersion = "33.0.1"; + buildToolsVersions = [ "31.0.0" ]; + platformVersions = [ "30" ]; + cmakeVersions = [ "3.18.1" ]; ndkVersion = "22.1.7171670"; + includeNDK = true; }; androidSdk = androidPkgs.androidsdk; gomobile = pkgs.gomobile.override { inherit androidPkgs; }; -in buildGoModule { +in buildGoPackage rec { pname = "go-waku"; version = "devel"; - vendorSha256 = "sha256-+W5PnVmD4oPh3a8Ik9Xn3inCI8shqEsdlkG/d6PQntk="; - GIT_COMMIT = "TODO"; - doCheck = false; + goPackagePath = "github.com/status-im/go-waku"; 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"; - GO111MODULE = "off"; - GOMOBILE = gomobile; - - shellHook = '' - env | grep -E '^(ANDROID|GO)' - ''; buildPhase = '' - runHook shellHook - unset GOARCH gomobile bind -x \ -target=android/arm64 \ -androidapi=23 \ -ldflags="-s -w" \ - -o ./build/lib/gowaku.aar \ - ./mobile + -o go-waku.aar \ + ${goPackagePath}/mobile + ''; + + installPhase = '' + mkdir -p $out + mv go-waku.aar $out/ ''; #buildPhase = '' @@ -47,7 +44,7 @@ in buildGoModule { # -target=ios \ # -iosversion=8.0 \ # -ldflags="-s -w" \ - # -o ./build/lib/Gowaku.xcframework \ + # -o ./build/lib/go-waku.xcframework \ # ./mobile #''; }