lez-programs/apps/amm/MACOS.md
2026-07-15 18:07:30 -03:00

96 lines
2.8 KiB
Markdown

# AMM UI on macOS
The AMM UI supports both Apple Silicon and Intel Macs through the Nix flake.
The project packages its QML wallet and AMM client libraries with relative
macOS loader paths, so a normal `nix run .` does not need `DYLD_LIBRARY_PATH`.
## One-time prerequisites
Install Nix in multi-user mode, make sure its daemon is running, and enable
flakes:
```sh
mkdir -p ~/.config/nix
printf '%s\n' 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf
nix --version
```
The build uses RISC Zero's Metal kernel build on Darwin. Apple Command Line
Tools alone do not provide the `metal` and `metallib` compilers. Install the
full Xcode application, select it, accept its licence, and install the Metal
Toolchain component when Xcode asks for it:
```sh
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license accept
xcodebuild -downloadComponent MetalToolchain
xcrun --sdk macosx --find metal
xcrun --sdk macosx --find metallib
```
The last two commands must print paths. Do not use `RISC0_SKIP_BUILD_KERNELS=1`
as a replacement: the pinned RISC Zero version still invokes the Metal build
for this dependency graph.
Leave at least 40 GiB free before the first build. Qt, Rust and Nix closures
are large; later runs reuse the Nix store cache.
## Build and run
From this directory:
```sh
nix build .
nix run .
```
The first start opens the AMM UI without a wallet. Select **Connect** to create
or open the wallet stored under `~/.lee/wallet/`.
## Recovery
### `nix: command not found` or no `/nix` volume
Open a new terminal after installing Nix. If the Nix volume is not mounted or
the daemon is not available, repair the Nix installation using the installer
for the installed Nix version. Check the actual service state before trying to
bootstrap it again:
```sh
test -x /nix/var/nix/profiles/default/bin/nix
sudo launchctl print system/org.nixos.nix-daemon
```
`launchctl bootstrap` can report an I/O error when the service is already in
an inconsistent state; it is not proof that the daemon is stopped.
### `xcrun: unable to find utility "metal"`
The active developer directory points at Command Line Tools or lacks the Metal
Toolchain component. Repeat the Xcode selection and Metal verification steps
above. This is an Apple-host prerequisite and cannot be packaged inside the
flake.
### The first build runs out of space
Remove only disposable build outputs, then collect dead Nix store paths:
```sh
rm -rf /private/tmp/amm-pr210-build
nix-store --gc
```
Do not remove `/nix/store` directly.
### A local flake lock error mentions an unlocked `amm_client` input
The committed `flake.lock` includes a hash for the repository-local client
input. Restore that file if a local experiment replaced it, then retry:
```sh
git restore flake.lock
nix flake metadata --no-write-lock-file
```
Run these commands from `apps/amm`.