cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
3.74k stars 275 forks source link

Android setup fails on darwin / M1 / Apple #1305

Open clotodex opened 1 week ago

clotodex commented 1 week ago

Describe the bug The nix install of the android sdk fails on the darwin architecture.

To reproduce android.enable=true on a macbook with an M processor

Logs

   … from call site
     at /nix/store/mnfbbcdbbwh3iif9m9xp8jnsgys65f2g-source/pkgs/development/mobile/androidenv/cmdline-tools.nix:10:7:
        9|   patchInstructions = ''
       10|     ${lib.optionalString (os == "linux") ''
         |       ^
       11|       # Auto patch all binaries
   … while calling 'optionalString'
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/strings.nix:268:5:
      267|     # String to return if condition is true
      268|     string: if cond then string else "";
         |     ^
      269|
   error:
   error: No Android SDK tarballs are available for system architecture: aarch64-darwin

Version 1.0.7 - no flakes, latest update

clotodex commented 1 week ago

Is there a workaround? If you an point me somewhere I can try myself at implementing it

domenkozar commented 1 week ago

cc @k3yss

k3yss commented 1 week ago

Hey, @clotodex it looks like a problem with the implementation of androidenv in nixpkgs. Here is a link to the discourse discussion about this issue.

clotodex commented 1 week ago

Yeah I found that too @k3yss but I thought it was fixed in https://github.com/NixOS/nixpkgs/pull/304716. Could it be that a) it actually got fixed, but the devenv rolling does not have the fix yet or b) this does not actually fix it for some reason or c) I misunderstood the discussion in the discourd and their way to resolve it is to just blame apple and use something legacy or rosetta?

Apart from me just wanting to make it work I am also wondering how we can have devenv support it "out of the box" since otherwise you have to go deep into nix do even start solving the issue. (Hence if we identify a workaround here I am happy to build that workaround into devenv to at least support it in some way out of the box)

clotodex commented 1 week ago

I think @k3yss it is actually not yet in devenv-rolling: https://github.com/cachix/devenv-nixpkgs/blob/4267e705586473d3e5c8d50299e71503f16a6fb6/pkgs/development/mobile/androidenv/compose-android-packages.nix#L31

I dont understand fully how the update cycle there works but that is for another issue :D

k3yss commented 1 week ago

@clotodex I currently don't have an access to a darwin device but if you want we can debug it together on discord. What I would do to start is instead of using devenv's nixpkgs I will use nixpkgs-unstable, since we don't employ any patches for android stuff

#devenv.yaml
inputs:
  nixpkgs:
    url:  github:NixOS/nixpkgs/nixpkgs-unstable
clotodex commented 1 week ago

Yes that would also be my plan I also dont have direct access but a coworker can check it out next week :)