Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Development on Nix

Trezor Suite provides two ways to use Nix: a Nix flake (flake.nix) and a shell.nix for environments without flakes enabled.

Prerequisites

Flakes

  • Nix installed with flakes enabled
  • Add experimental-features = nix-command flakes to ~/.config/nix/nix.conf

shell.nix (nix-shell)

  • Nix installed (no extra config needed)
  • Android and Rust tooling is opt-in via USE_ANDROID=1 / USE_RUST=1, see Optional plugins

Flake: Available Dev Shells

Default shell (web/desktop development)

Includes Node.js 24, Yarn, Playwright, Electron, and all build dependencies.

nix develop
# or explicitly:
nix develop .#default

Android shell (mobile development)

Includes everything in the default shell plus:

  • Java (JDK)
  • Android SDK (platforms, build tools, NDK)
  • Android Emulator with system images
  • A default AVD is auto-created on first run
nix develop .#android

Rust shell (e.g. transport-bluetooth development)

Includes everything in the default shell plus the Rust toolchain (rustc, cargo, rustfmt, cargo-cross).

nix develop .#rust

Common Workflows

Web / Desktop development

nix develop
yarn
yarn suite:dev          # Web app at http://localhost:8000
yarn suite:dev:desktop  # Electron desktop app

Mobile (Android) development

nix develop .#android
yarn
yarn native:start       # Start Metro bundler (in one terminal)
yarn a                  # Run on Android (in another terminal)

Running the Android emulator

nix develop .#android
# list available AVDs with:
avdmanager list avd
emulator -avd <avd-name>
emulator -avd Pixel_6_API_34

If you have troubles with your GPU acceleration you can disable it when running emulator like:

emulator -avd Pixel_6_API_34 -gpu swiftshader_indirect

Running tests

nix develop
yarn test:unit

VS Code environment (flakes)

Install the nix-env-selector extension and add the following to .vscode/settings.json:

"nixEnvSelector.useFlakes": true,
"nixEnvSelector.flakeShell": "rust"

Set flakeShell to default, android, or rust to match the shell you need. Reload VS Code after changing the settings. New terminals then open inside the selected shell.


shell.nix

For environments without flakes, use nix-shell with the root shell.nix.

Default (web/desktop)

nix-shell

Optional plugins

Plugins are enabled with environment variables set to 1. They are defined in .nix and add to the default shell.

VariablePluginDescription
USE_ANDROID=1android.nixAndroid shell (mobile development)
USE_RUST=1rust.nixRust shell (e.g. transport-bluetooth development)

Android

USE_ANDROID=1 nix-shell
yarn
yarn native:start       # Start Metro bundler (in one terminal)
yarn a                  # Run on Android (in another terminal)

Rust

Used by packages/transport-bluetooth:

USE_RUST=1 nix-shell
yarn workspace @trezor/transport-bluetooth dev:server

Combining plugins

USE_ANDROID=1 USE_RUST=1 nix-shell

The variables are read when nix-shell starts, so set them on the same command line (or export them first).