Skip to content
Grayson Adams edited this page Nov 26, 2026 · 2 revisions

This page is the short version of docs/setup.md, which has every command. Read Mac relay first if you have not chosen a Mac yet.

Placeholders: <relay-dir> is where the relay lives on the Mac, <mac-ip> is the Mac's private address (for example its Tailscale IP).

1. Prepare the Mac

  • No system sleep, restart after power loss, no automatic macOS installs.
  • Signed in to iCloud with the Apple ID the bridge will use.
  • Auto-login for the relay's user if it has to survive unattended reboots.
  • On Tailscale, key expiry disabled for the Mac.

The exact pmset and defaults commands are in setup.md, step 1.

2. Build and start the relay

git clone https://github.com/312-dev/macoun-matrix.git
mkdir -p <relay-dir>/bin <relay-dir>/logs <relay-dir>/state
cd macoun-matrix/tools/macoun-relay
go build -o <relay-dir>/bin/nac-relay ./tools/nac-relay
cd ../..
sed -e 's#@RELAY_DIR@#<relay-dir>#g' -e 's#@LISTEN_IP@#<mac-ip>#g' \
  tools/macoun-relay/launchd/dev.macoun.relay.plist.template \
  > ~/Library/LaunchAgents/dev.macoun.relay.plist
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/dev.macoun.relay.plist

Do not run nac-relay --setup. That option installs a LaunchAgent that listens on all interfaces.

On first start the relay creates a self-signed certificate and a bearer token under <relay-dir>/state/Library/Application Support/nac-relay/. You need three values from there for the bridge: the URL (https://<mac-ip>:5001), the token, and the SHA-256 fingerprint of the certificate:

D="<relay-dir>/state/Library/Application Support/nac-relay"
openssl x509 -in "$D/cert.pem" -outform der | shasum -a 256 | cut -d' ' -f1
pbcopy < "$D/token"   # paste it into your secret store; do not print it

3. Extract the hardware key

On the same Mac:

cd macoun-matrix/tools/extract-key
./build.sh
HOME=<relay-dir>/state ./extract-key

The output is a base64 string that identifies your Mac. Treat it as a secret. The key has to come from the Mac that runs the relay, so the device identity, the validation data and the anisette headers all describe the same machine.

4. Build the bridge on Linux

git clone https://github.com/312-dev/macoun-matrix.git
git clone https://github.com/OpenBubbles/rustpush.git
git -C rustpush checkout "$(cat macoun-matrix/third_party/rustpush-upstream.sha)"
git -C rustpush -c url.https://github.com/.insteadOf=git@github.com: \
  submodule update --init --recursive
docker build -t macoun-build:local macoun-matrix/docker -f macoun-matrix/docker/Dockerfile.build
docker run --rm --memory 6g \
  -v "$PWD/macoun-matrix:/src" -v "$PWD/rustpush:/rustpush:ro" \
  macoun-build:local bash -c 'git config --global --add safe.directory "*"; scripts/macoun-build-linux.sh build'

The binary is macoun-matrix/macoun-matrix. A first build takes a while (the Rust library is large) and needs about 6 GB of memory and 10 GB of disk. At run time the host needs libolm, libunwind and zlib; libheif and ffmpeg are optional.

There are no binary downloads. See the FAQ for why.

5. Configure and register

./macoun-matrix -e -c config.yaml                        # write the example config
# edit homeserver.address, homeserver.domain, appservice.address, database, permissions
./macoun-matrix -g -c config.yaml -r registration.yaml   # write the appservice registration

Add registration.yaml to your homeserver (for Synapse, app_service_config_files) and restart it.

6. Start and log in

Start the bridge with the relay settings in its environment (see Configuration):

MACOUN_NAC_RELAY_URL=https://<mac-ip>:5001 \
MACOUN_NAC_RELAY_TOKEN=... \
MACOUN_NAC_RELAY_CERT_FP=... \
./macoun-matrix -c config.yaml

In practice put these in a systemd unit's EnvironmentFile (mode 0600) or your secret manager, not on a command line.

Then start a chat with the bridge bot from your Matrix account, send login, choose the "Apple ID (External Key)" flow, and give it the hardware key, your Apple ID, password and the 2FA code. The start log should contain macoun-matrix starting and Hardware key: validation data from NAC relay.

7. Monitoring

The bridge posts a notice in your management room when the relay stops answering and when it is back (set bridge_status_notices: errors). For a watchdog that works when the bridge itself is down, see examples/monitoring/ and setup.md, step 7.

Clone this wiki locally