damus-io / android

Damus Android
Other
37 stars 4 forks source link

Nix environment doesn't work on m1 Mac #57

Open justinmoon opened 4 months ago

justinmoon commented 4 months ago
$ env NIXPKGS_ALLOW_UNFREE=1 NIXPKGS_ACCEPT_ANDROID_SDK_LICENSE=1 nix-shell
error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'nix-shell'
         whose name attribute is located at /nix/store/syidrpdhd0fzfl7d8zh9z7b3xljhrlcs-nixpkgs/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:352:7

       … while evaluating attribute 'ANDROID_HOME' of derivation 'nix-shell'

         at /Users/justin/code/damus-android/shell.nix:32:3:

           31| } // (if !use_android then {} else {
           32|   ANDROID_HOME = android-home;
             |   ^
           33|   NDK_HOME = ndk-home;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: No Android SDK tarballs are available for system architecture: aarch64-darwin
jb55 commented 4 months ago

I haven't set up macos for android dev yet, I don't think you can use nixpkgs for this on mac?

justinmoon commented 4 months ago

I have used https://github.com/tadfisher/android-nixpkgs in the past to install android SDK and everything like that via nix on a Mac.

Not sure if it will be useful or now, but https://github.com/rustshop/flakebox basically extracted Fedimint's cross-compilation setup into a separate project other people can use. It doesn't deal with Android SDK at all, but does do cross-compilation very well. @dpc can answer any questions you have!

dpc commented 4 months ago

It doesn't deal with Android SDK at all,

Correction: It does allow picking and customizing SDK components, AFAIK/AFAIU.

jb55 commented 4 months ago

On Thu, Feb 15, 2024 at 05:42:48AM -0800, Justin Moon wrote:

I have used https://github.com/tadfisher/android-nixpkgs in the past to install android SDK and everything like that via nix on a Mac.

nice, someone should update our scripts to use this.

Not sure if it will be useful or now, but https://github.com/rustshop/flakebox basically extracted Fedimint's cross-compilation setup into a separate project other people can use. It doesn't deal with Android SDK at all, but does do cross-compilation very well. @dpc can answer any questions you have!

rust handles everything cross-compilation wise, what's the point of this?

dpc commented 4 months ago

rust handles everything cross-compilation wise, what's the point of this?

C / C++ dependencies is the biggest reason.

jb55 commented 4 months ago

doesn't build.rs handle cross compliation? at least thats how I do it with secp and nostrdb

dpc commented 4 months ago

It relies on availability of cross-compiler toolchain, sometimes also already cross-compiled libraries. Flakebox basically brings them in using Nix, pinned to specific versions, and sets up all env variables so it all works smoothly. Plus some other things that are optional.