Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions .github/workflows/mac-tools.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Mac tools

# Builds universal (arm64 + x86_64) binaries of nac-relay and extract-key and
# attaches them to a release. These two tools are AGPL-3.0 and contain no
# rustpush code, so unlike the bridge they can be distributed as binaries
# (see NOTICE.md). Pull requests that touch this file build without
# publishing.

on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: Existing release tag to build and attach the tools to
required: true
pull_request:
paths:
- .github/workflows/mac-tools.yml

permissions:
contents: read

jobs:
build:
name: Build universal binaries
runs-on: macos-15
env:
TAG: ${{ inputs.tag || github.event.release.tag_name || 'test' }}
# The supported macOS range starts at 13.
MACOSX_DEPLOYMENT_TARGET: "13.0"
CGO_ENABLED: "1"
steps:
- uses: actions/checkout@v5
with:
ref: ${{ inputs.tag || github.ref }}
- uses: actions/setup-go@v6
with:
go-version-file: tools/macoun-relay/go.mod
- name: Build both architectures
run: |
set -euo pipefail
out="$PWD/out"; mkdir -p "$out"
for a in arm64:arm64 amd64:x86_64; do
goarch=${a%%:*}; clangarch=${a##*:}
export GOARCH=$goarch CGO_CFLAGS="-arch $clangarch" CGO_LDFLAGS="-arch $clangarch"
(cd tools/macoun-relay && go build -trimpath -o "$out/nac-relay-$goarch" ./tools/nac-relay)
(cd tools/extract-key && go build -trimpath -o "$out/extract-key-$goarch" .)
done
- name: Merge into universal binaries and check them
run: |
set -euo pipefail
cd out
for t in nac-relay extract-key; do
lipo -create -output "$t" "$t-arm64" "$t-amd64"
archs=$(lipo -archs "$t")
echo "$t: $archs"
[ "$archs" = "x86_64 arm64" ] || [ "$archs" = "arm64 x86_64" ]
for s in arm64 x86_64; do
lipo "$t" -thin "$s" -output "/tmp/$t-$s"
otool -l "/tmp/$t-$s" | grep -A3 LC_BUILD_VERSION | grep -q 'minos 13.0'
done
done
# Both slices start. nac-relay -h prints its flags and exits 0;
# the x86_64 slice runs under Rosetta on this runner.
./nac-relay -h
arch -x86_64 ./nac-relay -h
- name: Package
run: |
set -euo pipefail
name="macoun-mac-tools-$TAG"
mkdir -p "pkg/$name"
cp out/nac-relay out/extract-key "pkg/$name/"
cp tools/macoun-relay/launchd/dev.macoun.relay.plist.template "pkg/$name/"
cp tools/macoun-relay/LICENSE "pkg/$name/LICENSE"
cat > "pkg/$name/SOURCE.txt" <<EOF
nac-relay and extract-key from macoun-matrix $TAG ($(git rev-parse HEAD)),
universal binaries for macOS 13 and later, licensed AGPL-3.0 (LICENSE).
Corresponding source: https://github.com/${{ github.repository }}/tree/$(git rev-parse HEAD)/tools
Install steps: docs/setup.md in that tree.
EOF
tar -C pkg -czf "$name.tar.gz" "$name"
shasum -a 256 "$name.tar.gz" > sha256sums-mac-tools.txt
cat sha256sums-mac-tools.txt
- uses: actions/upload-artifact@v4
with:
name: mac-tools
path: |
macoun-mac-tools-*.tar.gz
sha256sums-mac-tools.txt

publish:
name: Attach to the release
needs: build
if: github.event_name != 'pull_request'
runs-on: ubuntu-24.04
permissions:
contents: write
env:
TAG: ${{ inputs.tag || github.event.release.tag_name }}
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/download-artifact@v4
with:
name: mac-tools
- run: gh release upload "$TAG" macoun-mac-tools-*.tar.gz sha256sums-mac-tools.txt --clobber --repo "${{ github.repository }}"
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

* Added universal macOS binaries of `nac-relay` and `extract-key` to releases
(`macoun-mac-tools-<tag>.tar.gz`). The bridge stays source only.
* Added bubble and screen effects in both directions, through the
`com.beeper.imessage.effect` content key. Outbound effects are sent on text
messages only. See [docs/effects.md](docs/effects.md).
Expand Down
16 changes: 11 additions & 5 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,18 @@ compatible with this as a Larger Work, MPL section 3.3).

## Binaries

This repository publishes source only. A built binary links MPL-2.0, AGPL-3.0
The bridge is published as source only. A built bridge links MPL-2.0, AGPL-3.0
and SSPL v1 code. Building and running it for your own account is the intended
use. Distributing a binary, or offering it to third parties as a service,
brings SSPL obligations that this combination with AGPL and MPL code cannot
satisfy, so the project does not publish binaries and asks that you do not
either.
use. Distributing a bridge binary, or offering it to third parties as a
service, brings SSPL obligations that this combination with AGPL and MPL code
cannot satisfy, so the project does not publish bridge binaries and asks that
you do not either.

The Mac tools are different. `nac-relay` (`tools/macoun-relay/`) and
`extract-key` (`tools/extract-key/`) are AGPL-3.0, have no Go dependencies and
contain no rustpush code. Releases carry universal macOS binaries of the two
(`macoun-mac-tools-<tag>.tar.gz`, built by `.github/workflows/mac-tools.yml`),
with the AGPL-3.0 text and the source commit in the archive.

## corten-matrix parts that are not in its public source

Expand Down
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ Mac does not interrupt messaging. Details:

The full walk-through is [docs/setup.md](docs/setup.md). In short:

1. **On the Mac:** build `tools/macoun-relay`, install it as a LaunchAgent
1. **On the Mac:** download or build `nac-relay`, install it as a LaunchAgent
bound to the Mac's private address, and note the relay token and
certificate fingerprint.
2. **On the Mac:** run `tools/extract-key` once to get the hardware key the
2. **On the Mac:** run `extract-key` once to get the hardware key the
bridge logs in with.
3. **On Linux:** build the bridge.

Expand Down Expand Up @@ -99,7 +99,11 @@ The full walk-through is [docs/setup.md](docs/setup.md). In short:
`MACOUN_NAC_RELAY_CERT_FP`), then log in from Matrix through the bridge bot
with the hardware key, your Apple ID password and a 2FA code.

There are no binary releases; see [Licence](#licence) for why.
The bridge has no binary releases; see [Licence](#licence) for why. The two
Mac tools do: each [release](https://github.com/312-dev/macoun-matrix/releases)
carries `macoun-mac-tools-<tag>.tar.gz` with universal `nac-relay` and
`extract-key` binaries for macOS 13 and later, so the Mac needs no Go
toolchain.

## Configuration

Expand Down Expand Up @@ -175,9 +179,10 @@ open code and a Mac you own. Almost all of the bridge is their work; thank you.
it in `third_party/patches/rustpush/`.

[NOTICE.md](NOTICE.md) has the file-level map. Because a built binary links
AGPL and SSPL code together, this project publishes source only: build the
bridge for your own account, and do not redistribute binaries or run it as a
service for other people.
AGPL and SSPL code together, this project publishes the bridge as source only:
build it for your own account, and do not redistribute bridge binaries or run
it as a service for other people. The Mac tools contain no SSPL code, which is
why their binaries can be published.

## Disclaimer

Expand Down
6 changes: 4 additions & 2 deletions docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ AGPL-3.0 or SSPL v1 is included, linked, loaded at run time or required.
Because AGPL code is linked into the binary, treat a built binary as AGPL-3.0.
SSPL rustpush makes it unsuitable for distribution or for offering to other
people as a service: build it for your own account and do not hand out
binaries. The project publishes source only for the same reason. [NOTICE.md](../NOTICE.md) has the file-level map and the source
commits.
binaries. The project publishes the bridge as source only for the same reason.
The two Mac tools contain no rustpush code, so releases do carry macOS
binaries of them. [NOTICE.md](../NOTICE.md) has the file-level map and the
source commits.

## Architecture

Expand Down
26 changes: 25 additions & 1 deletion docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,25 @@ defaults read /Library/Preferences/com.apple.SoftwareUpdate

## 2. Build and run the relay on the Mac

Either download the release build (macOS 13 and later, Intel or Apple
Silicon):

```bash
mkdir -p <relay-dir>/bin <relay-dir>/logs <relay-dir>/state
cd <relay-dir>
T=<tag> # for example v0.1.0
curl -fsSLO "https://github.com/312-dev/macoun-matrix/releases/download/$T/macoun-mac-tools-$T.tar.gz"
curl -fsSL "https://github.com/312-dev/macoun-matrix/releases/download/$T/sha256sums-mac-tools.txt" | shasum -a 256 -c
tar -xzf "macoun-mac-tools-$T.tar.gz"
cp "macoun-mac-tools-$T/nac-relay" bin/
```

Download with `curl` as above rather than a browser: a browser marks the file
as quarantined and Gatekeeper refuses to run an unsigned binary. The archive
also holds `extract-key` (step 3) and the LaunchAgent template.

Or build it from source:

```bash
git clone https://github.com/312-dev/macoun-matrix.git
mkdir -p <relay-dir>/bin <relay-dir>/logs <relay-dir>/state
Expand All @@ -49,8 +68,10 @@ Install it as a LaunchAgent from the template. **Never run `nac-relay
all interfaces.

```bash
# The template is in the release archive, or at
# tools/macoun-relay/launchd/ in a source checkout.
sed -e 's#@RELAY_DIR@#<relay-dir>#g' -e 's#@LISTEN_IP@#<mac-ip>#g' \
tools/macoun-relay/launchd/dev.macoun.relay.plist.template \
<path-to>/dev.macoun.relay.plist.template \
> ~/Library/LaunchAgents/dev.macoun.relay.plist
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/dev.macoun.relay.plist
launchctl print gui/$(id -u)/dev.macoun.relay | grep -E 'state|pid'
Expand Down Expand Up @@ -95,6 +116,9 @@ Only needed for a new login. The key must come from the same Mac that runs the
relay, so the identity matches the NAC data and anisette.

```bash
# From the release archive of step 2:
HOME=<relay-dir>/state <relay-dir>/macoun-mac-tools-<tag>/extract-key
# Or from source:
cd macoun-matrix/tools/extract-key
./build.sh # or: go build -o extract-key .
HOME=<relay-dir>/state ./extract-key
Expand Down
Loading