From e9d6656c51d93781f457b89bb9ee44b6fc0425f4 Mon Sep 17 00:00:00 2001 From: M57 <41645758+Hy4ri@users.noreply.github.com> Date: Sat, 19 Sep 2026 11:18:53 +0300 Subject: [PATCH] fix: enable emulator keyboard in Nix dev shell (#1193) --- README.md | 15 +++++++++++++++ flake.nix | 11 +++++++++++ 2 files changed, 26 insertions(+) diff --git a/README.md b/README.md index d2a72800..b96711a7 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,21 @@ If Hermes Mobile is useful to you, consider supporting its development on [Ko-fi _Note: For release builds, ensure keystore environment variables (`KEYSTORE_PATH`, `KEYSTORE_PASSWORD`, `KEY_ALIAS`, `KEY_PASSWORD`) are configured, or let the GitHub Actions release workflow handle it on tag push (`v*`)._ +### Nix emulator + +The Nix development shell enables physical keyboard input in an existing +`hermes_dev` AVD configuration. It respects `ANDROID_AVD_HOME` and +`ANDROID_USER_HOME`, defaulting to `~/.android/avd`. + +Close any running emulator, then cold boot once to apply the setting: + +```bash +nix develop --command emulator -avd hermes_dev -no-snapshot-load +``` + +Subsequent launches can omit `-no-snapshot-load`. Create the `hermes_dev` AVD +first if it does not exist; the shell does not create one. + --- ## Authentication diff --git a/flake.nix b/flake.nix index 7564f81b..88a42a3a 100644 --- a/flake.nix +++ b/flake.nix @@ -93,6 +93,17 @@ # Writable gradle home mkdir -p "$GRADLE_USER_HOME" + # Enable host keyboard input for the project's existing AVD. + hermesAvdConfig="''${ANDROID_AVD_HOME:-''${ANDROID_USER_HOME:-$HOME/.android}/avd}/hermes_dev.avd/config.ini" + if [ -f "$hermesAvdConfig" ]; then + if ${pkgs.gnugrep}/bin/grep -q '^hw\.keyboard[[:space:]]*=' "$hermesAvdConfig"; then + ${pkgs.gnused}/bin/sed -i 's/^hw\.keyboard[[:space:]]*=.*/hw.keyboard=yes/' "$hermesAvdConfig" + else + printf '\nhw.keyboard=yes\n' >> "$hermesAvdConfig" + fi + fi + unset hermesAvdConfig + # ADB Screen Resolution Aliases alias avd-phone='adb shell wm size 1440x3120 && adb shell wm density 500' alias avd-phone-fhd='adb shell wm size 1080x2400 && adb shell wm density 420'