devenv icon indicating copy to clipboard operation
devenv copied to clipboard

Android setup fails on darwin / M1 / Apple

Open clotodex opened this issue 1 year ago • 11 comments

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 avatar Jun 27 '24 17:06 clotodex

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

clotodex avatar Jun 27 '24 17:06 clotodex

cc @k3yss

domenkozar avatar Jun 28 '24 09:06 domenkozar

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.

k3yss avatar Jun 28 '24 10:06 k3yss

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 avatar Jun 28 '24 10:06 clotodex

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

clotodex avatar Jun 28 '24 10:06 clotodex

@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

k3yss avatar Jun 28 '24 10:06 k3yss

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

clotodex avatar Jun 28 '24 12:06 clotodex

@clotodex ping!

k3yss avatar Jul 29 '24 05:07 k3yss

Thanks for the ping. It is working with unstable :) I needed to configure some darwin "systems" as well but now it is working

I can post the config in ~2 weeks if you are interested, that's when i have mac access again

clotodex avatar Jul 29 '24 08:07 clotodex

@clotodex Do you need to configure something special for running android on mac? If yes, it would be great to look at the config and maybe automate some of it.

k3yss avatar Jul 29 '24 08:07 k3yss

Not for our minimal setup in the end (had some legacy darwin things around but removing them did not break it) Disclaimer though: we dont have a full android setup though - just enough to make flutter work. For reference:

  languages.dart.enable = true;
  languages.dart.package = pkgs-master.flutter;
  android = {
    systemImageTypes = [];
    abis = [];
    emulator = {
      enable = false;
    };
    sources.enable = false;
    systemImages.enable = false;
    ndk.enable = false;
    googleAPIs.enable = false;
    googleTVAddOns.enable = false;
    extras = [];
    android-studio.enable = false;
    enable = true;
    flutter.enable = true;
    flutter.package = pkgs-master.pkgs.flutter;
  };
  env.FLUTTER_ROOT = lib.mkForce pkgs-master.flutter;
  env.DART_ROOT    = lib.mkForce "${pkgs-master.flutter}/bin/cache/dart-sdk";

However I still need unstable nixpkgs - it does not run with the default devenv ones

clotodex avatar Sep 04 '24 21:09 clotodex

Everything works fine after this PR https://github.com/cachix/devenv-nixpkgs/issues/2

Tested on m1 processor mac

k3yss avatar Dec 17 '24 18:12 k3yss