Android adb + expo configuration

HI all, I develop a React Native + Expo application and am unable to make it work on Nix, the yarn android command tries to run adb from my home directory, which results in the following error:

yarn run v1.22.19
$ expo run:android
Error: Could not start dynamically linked executable: /home/arthur/Android/Sdk/platform-tools/adb
NixOS cannot run dynamically linked executables intended for generic
linux environments out of the box. For more information, see:
https://nix.dev/permalink/stub-ld
Error: /home/arthur/Android/Sdk/platform-tools/adb exited with non-zero code: 127
    at ChildProcess.completionListener (/home/arthur/Code/myhabit/app/node_modules/@expo/spawn-async/build/spawnAsync.js:52:23)
    at Object.onceWrapper (node:events:629:26)
    at ChildProcess.emit (node:events:514:28)
    at maybeClose (node:internal/child_process:1105:16)
    at Socket.<anonymous> (node:internal/child_process:457:11)
    at Socket.emit (node:events:514:28)
    at Pipe.<anonymous> (node:net:337:12)
    ...
    at Object.spawnAsync [as default] (/home/arthur/Code/myhabit/app/node_modules/@expo/spawn-async/build/spawnAsync.js:17:21)
    at ADBServer.startAsync (/home/arthur/Code/myhabit/app/node_modules/@expo/cli/build/src/start/platforms/android/ADBServer.js:44:77)
    at ADBServer.runAsync (/home/arthur/Code/myhabit/app/node_modules/@expo/cli/build/src/start/platforms/android/ADBServer.js:75:20)
    at Object.getAttachedDevicesAsync (/home/arthur/Code/myhabit/app/node_modules/@expo/cli/build/src/start/platforms/android/adb.js:134:38)
    at Object.getDevicesAsync (/home/arthur/Code/myhabit/app/node_modules/@expo/cli/build/src/start/platforms/android/getDevices.js:10:43)
    at AndroidDeviceManager.resolveAsync (/home/arthur/Code/myhabit/app/node_modules/@expo/cli/build/src/start/platforms/android/AndroidDeviceManager.js:65:48)
    at Object.resolveDeviceAsync (/home/arthur/Code/myhabit/app/node_modules/@expo/cli/build/src/run/android/resolveDevice.js:11:74)
    at Object.resolveOptionsAsync (/home/arthur/Code/myhabit/app/node_modules/@expo/cli/build/src/run/android/resolveOptions.js:19:43)
    at async runAndroidAsync (/home/arthur/Code/myhabit/app/node_modules/@expo/cli/build/src/run/android/runAndroidAsync.js:31:19)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I have tried installing everything with home-manager, and everything under system packages

I could not find any tutorials or any other material online, so any help is appreciated
I am also a complete noob at Nix, so I might be missing something really obvious!

Have you resolved this? I’m having the same problem.

Yes! Completely forgot to come back here and update this, thank you!

What worked for me was creating a flake for my project with everything I needed and starting the emulator from command line.

You can put the flake in your project and enter the shell with nix develop.

This is the flake I was using:

{
inputs = {
  nixpkgs.url = "github:NixOS/nixpkgs/23.11";
  flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
  flake-utils.lib.eachDefaultSystem (system:
    let
      pkgs = import nixpkgs {
        inherit system;
        config = {
          android_sdk.accept_license = true;
          allowUnfree = true;
        };
      };
      androidComposition = pkgs.androidenv.composeAndroidPackages {
        buildToolsVersions = [ "34.0.0" "33.0.1" ];
        platformVersions = [ "34"];
        abiVersions = [ "x86_64" ];
        includeEmulator = true;
        emulatorVersion = "33.1.20";
        includeSystemImages = true;
        systemImageTypes = [ "google_apis" ];
        includeNDK = true;
        ndkVersions = ["25.1.8937393"];
        cmakeVersions = [ "3.22.1" ];
      };
      androidSdk = androidComposition.androidsdk;
    in
    {
      devShell =
        with pkgs; mkShell {
          ANDROID_SDK_ROOT = "${androidSdk}/libexec/android-sdk";
          GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${androidSdk}/libexec/android-sdk/build-tools/34.0.0/aapt2";
          LD_LIBRARY_PATH="${libglvnd}/lib";
          buildInputs = [
            androidSdk

            nodejs
            corepack
            jdk17
            crudini
          ];
        };
    });
}