cachix / devenv

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

Android setup fails on darwin / M1 / Apple #1305

Open clotodex opened 4 months ago

clotodex commented 4 months 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 4 months ago

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

domenkozar commented 4 months ago

cc @k3yss

k3yss commented 4 months 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 4 months 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 4 months 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 4 months 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 4 months ago

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

k3yss commented 3 months ago

@clotodex ping!

clotodex commented 3 months ago

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

k3yss commented 3 months ago

@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.

clotodex commented 2 months ago

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