Document the build-time environment variables for configuring default paths and version information: - MAS_SHARE_DIR: Base directory for all bundled resources - MAS_VERSION: Override version string - Individual path overrides for fine-grained control Include examples for generic packaging and Nix derivations. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
5.8 KiB
Installation
Pre-built binaries
Pre-built binaries can be found attached on each release, for Linux on both x86_64 and aarch64 architectures.
Each archive contains:
- the
mas-clibinary - assets needed for running the service, including:
share/assets/: the built frontend assetsshare/manifest.json: the manifest for the frontend assetsshare/policy.wasm: the built OPA policiesshare/templates/: the default templatesshare/translations/: the default translations
The location of all these assets can be overridden in the configuration file.
Example shell commands to download and extract the mas-cli binary:
ARCH=x86_64 # or aarch64
OS=linux
VERSION=latest # or a specific version, like "v0.1.0"
# URL to the right archive
URL="https://github.com/element-hq/matrix-authentication-service/releases/${VERSION}/download/mas-cli-${ARCH}-${OS}.tar.gz"
# Create a directory and extract the archive in it
mkdir -p /path/to/mas
curl -sL "$URL" | tar xzC /path/to/mas
# This should display the help message
/path/to/mas/mas-cli --help
Using the Docker image
A pre-built Docker image is available here: ghcr.io/element-hq/matrix-authentication-service:latest
The latest tag is built using the latest release.
The main tag is built from the main branch, and each commit on the main branch is also tagged with a stable sha-<commit sha> tag.
The image can also be built from the source:
- Get the source
git clone https://github.com/element-hq/matrix-authentication-service.git cd matrix-authentication-service - Build the image
docker build -t mas .
Building from the source
Building from the source requires:
- The latest stable Rust toolchain
- Node.js (18 and later) and npm
- the Open Policy Agent binary (or alternatively, Docker)
- Get the source
git clone https://github.com/element-hq/matrix-authentication-service.git cd matrix-authentication-service - Build the frontend
This will produce a
cd frontend npm ci npm run build cd ..frontend/distdirectory containing the built frontend assets. This folder, along with thefrontend/dist/manifest.jsonfile, can be relocated, as long as the configuration file is updated accordingly. - Build the Open Policy Agent policies
OR, if you don't have
cd policies make cd ..opainstalled and want to build through the OPA docker imageThis will produce acd policies make DOCKER=1 cd ..policies/policy.wasmfile containing the built OPA policies. This file can be relocated, as long as the configuration file is updated accordingly. - Compile the CLI
cargo build --release - Grab the built binary
cp ./target/release/mas-cli ~/.local/bin # Copy the binary somewhere in $PATH mas-cli --help # Should display the help message
Packaging for distributions
When packaging MAS for Linux distributions (e.g., Nix, Debian, RPM), you can configure default paths and version information at build time using environment variables. This avoids the need to patch source files.
Build-time environment variables
MAS_SHARE_DIR
Sets the base directory for all bundled resources. When set, the following paths are derived automatically:
| Resource | Default path |
|---|---|
| Templates | ${MAS_SHARE_DIR}/templates/ |
| Assets | ${MAS_SHARE_DIR}/assets/ |
| Manifest | ${MAS_SHARE_DIR}/manifest.json |
| Translations | ${MAS_SHARE_DIR}/translations/ |
| Policy | ${MAS_SHARE_DIR}/policy.wasm |
If MAS_SHARE_DIR is not set (dev mode), paths default to source tree locations (./templates/, ./frontend/dist/, etc.).
MAS_VERSION
Overrides the version string reported by mas-cli --version and in telemetry.
If not set, the version is determined from git describe (if available) or falls back to the version in Cargo.toml.
Individual path overrides
For fine-grained control, individual paths can be overridden (these take precedence over MAS_SHARE_DIR):
MAS_TEMPLATES_PATH: Path to the templates directoryMAS_ASSETS_PATH: Path to the assets directoryMAS_ASSETS_MANIFEST_PATH: Path to the assets manifest fileMAS_TRANSLATIONS_PATH: Path to the translations directoryMAS_POLICY_PATH: Path to the policy WASM module
Example: Building for /usr/share/mas
# Build frontend and policies first
(cd frontend && npm ci && npm run build)
(cd policies && make)
# Build the binary with custom paths
export MAS_SHARE_DIR=/usr/share/mas
export MAS_VERSION=1.2.3
cargo build --release
# Install
install -Dm755 target/release/mas-cli /usr/bin/mas-cli
install -Dm644 policies/policy.wasm /usr/share/mas/policy.wasm
install -Dm644 frontend/dist/manifest.json /usr/share/mas/manifest.json
cp -r frontend/dist/* /usr/share/mas/assets/
cp -r templates /usr/share/mas/templates
cp -r translations /usr/share/mas/translations
Next steps
The service needs some configuration to work. This includes random, private keys and secrets. Follow the configuration guide to configure the service.