rvolosatovs / nixify

Simple and extensible nix build library for real-world projects
MIT License
33 stars 1 forks source link

How compile for android #199

Open mamcx opened 10 months ago

mamcx commented 10 months ago

This is a continuation from this issue

I have a repo here:

https://github.com/mamcx/RustStoreNix/tree/nixify

I must compile on macOS, Linux with targets windows, linux musl, android, ios. But my major problem is with android. I need:

def archTriplets = [
        'armeabi-v7a': 'armv7-linux-androideabi',
        'arm64-v8a'  : 'aarch64-linux-android',
]

I tried with:

❯ nix --version
nix (Nix) 2.18.1
{
  inputs.nixify.url = github:rvolosatovs/nixify;

  outputs = {nixify, ...}:
    nixify.lib.rust.mkFlake {
      src = ./.;
      name = "rust-workspace";

      build.workspace = true;
      clippy.workspace = true;
      test.workspace = true;
    };
}

And get :

❯ nix develop
warning: Git tree '/Users/mamcx/Proyectos/Apps' is dirty
(nix:nix-shell-env) bash-5.2$ cargo build
+ command cargo build
   Compiling ring v0.17.6
   Compiling zstd-sys v2.0.9+zstd.1.5.5
   Compiling generic-array v0.14.7
   Compiling globset v0.4.14
   Compiling rustix v0.38.26
   Compiling pin-project v1.1.3
   Compiling walkdir v2.4.0
   Compiling libsqlite3-sys v0.27.0
   Compiling tracing-subscriber v0.3.18
   Compiling thiserror v1.0.50
   Compiling phf_codegen v0.11.2
   Compiling phf v0.11.2
   Compiling parse-zoneinfo v0.3.0
error: linking with `cc` failed: exit status: 1
rvolosatovs commented 10 months ago

Thank you for the report! I've file a PR to your repo https://github.com/mamcx/RustStoreNix/pull/1 with an example.

At this time it is assumed that Cargo.toml resides at src, but in your case there are two separate workspaces in the repository and no top-level Cargo.toml, which is not currently supported - I flipped it around and moved RustStore to top-level to work around that.

I also had to remove the custom .cargo target build config to use the correct linker/toolchain during the build

mamcx commented 10 months ago

Thank you!

I have checked and it works. The modifications in your PR are acceptable to me.

A few questions: