Installation
Install Aperture with Nix as a per-user service, configure it, and run it on NixOS or any Linux host with user systemd.
Aperture is packaged with Nix and runs as a per-user desktop service on NixOS (or any Linux host with user systemd).
For the single-container deployment, see Docker. For local source development, see Development.
Build and install
From the repository:
nix build .#aperture
./result/bin/aperture-server --helpInstall into your user profile:
nix profile install .#apertureThe package provides:
aperture-server— the supervisor, its HTTP API and the local admin commandsaperture-mount-session/aperture-unmount-session— privileged overlay helpers (sudo)browser-session-wrapper— bwrap Chromium launcher used by user systemd units- systemd user units under
$out/share/systemd/user/(Nix fixup may also link$out/lib/systemd/user/) - Traefik static config template under
$out/share/aperture/traefik/ - sudoers snippet under
$out/share/aperture/sudoers/
Configuration
Create ~/.config/aperture/aperture.yaml (or set APERTURE_* environment variables). Required values include:
store_root,cold_root,database_path,runtime_root— storage and runtime state directories; see Storageexternal_base_url— public URL Traefik serves (for generated connection and signed-file links)embed_allowed_origins— optional origins of other web apps that embed shared sessions (see Session sharing)- MCP settings — enabled by default; see the example below
channels— browser channel registry (executablepaths only; API accepts channel names)metrics_address— optional Prometheus metrics listener, disabled by default; see Monitoringthumbnails_persist_on_suspend— save session and tab thumbnails when a session suspends (defaulttrue); the page list forbrowser/statusis saved either way; see Thumbnailsallow_personal_tenants— let users and administrators create personal tenants (defaulttrue)auto_create_personal_tenant— give every new user a tenant of their own, with every tenant permission (defaultfalse, requiresallow_personal_tenants); see Personal tenantsbrowser_pid_namespace— run each browser in its own PID namespace, so a session cannot see or signal other processes (defaulttrue). bwrap must be able to mount a new procfs; container runtimes that mask parts of/procprevent that, see Docker
Example:
store_root: /home/USER/.local/state/aperture
runtime_root: /run/user/UID/aperture
external_base_url: https://browser.example.test
listen_address: 127.0.0.1:8080
mcp_enabled: true
browser_tools_default: core,vision,network
tool_output_max_bytes: 16777216
signed_file_url_ttl: 15m
signed_file_url_max_ttl: 24h
login_methods: [password, api_token, passkey, oidc]
web_session_lifetime: 720h
web_session_idle_timeout: 24h
channels:
chromium:
executable: /run/current-system/sw/bin/chromium
default_args: []The first available login_methods entry is the default in the login dialog. password and api_token show forms; passkey starts WebAuthn; oidc expands to the providers below in their configured order.
To enable OIDC login, register ${external_base_url}/auth/oidc/PROVIDER_ID/callback with the provider and add it to the config:
oidc_providers:
- id: company
display_name: Company account
issuer_url: https://accounts.example.test
client_id: aperture
client_secret: REPLACE_ME
scopes: [openid, profile, email]
auto_provision: falseTo keep the secret out of the config file, for example when Nix generates it into the world-readable store, set client_secret_file instead of client_secret. Each provider needs exactly one of them. Aperture reads the file at startup and strips one trailing newline; the path must be absolute and the file non-empty and readable by the Aperture user.
oidc_providers:
- id: company
display_name: Company account
issuer_url: https://accounts.example.test
client_id: aperture
client_secret_file: /run/secrets/aperture-oidc-companyWith auto_provision: false, a system administrator must create the user first. Aperture links the provider identity only when the provider returns a verified email matching that user. Set auto_provision: true to create users on first login. Tenant access still comes from the user's tenant memberships, unless personal tenants are enabled.
Authenticated users can register discoverable passkeys from the web UI. Aperture derives the WebAuthn RP ID and origin from external_base_url, so changing its hostname makes credentials registered for the old RP unavailable. Passkey registration requires an existing account session; passkeys do not provision users.
Users with an email address can set an Argon2id password from the web UI. They can also enable TOTP for password login; enrollment creates ten one-time recovery codes that are shown once and stored only as SHA-256 hashes. OIDC and passkey login remain available when TOTP is enabled.
The central Streamable HTTP MCP endpoint is /mcp; the per-session endpoint is /sessions/:sessionId/mcp. Central MCP requires an Aperture API bearer token (apt_<tokenId>_<secret>). Per-session MCP accepts an authorized API bearer token or the owner-only sessionToken (aps_<sessionId>_<secret>). Share links instead use editor (ape_) and viewer (apv_) capabilities with narrower live-session access; editors may also record and manage session files. They do not authorize MCP or other /api/* routes. Signed session-file URLs use apf_<payload>.<signature> query tokens. OIDC, passkey, and password browser sessions authorize the web UI and same-origin API or live-session requests, but not MCP clients.
Storage
Aperture keeps its persistent state in three separately configurable places:
| Setting | Holds | Filesystem |
|---|---|---|
store_root (hot) | Session overlay state of running and stopped sessions: sessions/<bucket>/<id>/{upper,work,merged,cache,metadata}, plus artifacts and deployment state unless configured elsewhere | Local disk. overlayfs cannot use an NFS upper directory. |
cold_root (cold) | Snapshots (snapshots/<bucket>/<id>/profile) and session files (sessions/<bucket>/<id>/files) | Local disk or NFS v3 or later with a lock manager. Defaults to store_root. |
database_path | The SQLite database | Local disk. SQLite locking is unreliable on NFS and the database can be corrupted there. Defaults to store_root/aperture.db. |
runtime_root holds transient state such as runtime env files and is usually on a tmpfs; cold_root must not overlap it.
Set store_root and cold_root in the config file, not through environment variables or flags. The sudo mount helpers read only the root-owned config file, and they must see the same roots as the service. aperture-server serve refuses to start when the helper config sets a different store_root or cold_root.
cold_root holds a .aperture-root marker with the install ID stored in the database. aperture-server serve checks it before using cold_root:
- A marker with this install's ID: start.
- A marker with another ID: refuse to start.
cold_rootholds another install's data, or the database was replaced. If the database was restored from a backup older than this marker or recreated for the same data, replace the contents ofcold_root/.aperture-rootwith the install ID the error prints. - No marker, and
cold_rootisstore_root, or the database has no snapshot that garbage collection has not removed and no session that has not expired: write the marker and start. Upgraded installs that keep the defaultcold_rootget their marker this way. - No marker, a separate
cold_root, and such snapshots or sessions exist: refuse to start. The share is not mounted, orcold_rootpoints somewhere else than the data.
When cold_root is on NFS:
- Export it without root squashing to the Aperture host (
no_root_squash). The mount helper runs as root, creates each session's files directories there, and overlayfs reads snapshot layers with the credentials of the root that mounted them, including private profile files. - Mount the share before the first start. A fresh install marks whatever directory is at
cold_root, so starting before the mount marks the bare mount point, and snapshots and session files land there until the share is mounted over them. Once the install has data, the missing marker of an unmounted share stops Aperture from starting. - Snapshots are overlay lower layers of the sessions created from them; do not change them from another host.
Promotion copies the session's overlay upper directory from store_root into the new snapshot under cold_root, and hard-links files the snapshot shares with its parent snapshot, which is on the same filesystem.
Moving snapshots and session files to a new cold_root
When cold_root differs from store_root, aperture-server serve refuses to start while snapshots or session files remain in the old locations under store_root, so they cannot silently disappear. To move them:
- Stop or suspend every running session, then stop both API colors (
aperture@blue,aperture@green). - Set
cold_rootin the config file. - Run
aperture-server storage migrate --config /etc/aperture/aperture.tomlas the Aperture user. - Start Aperture again.
The command refuses to run while any session overlay is mounted. On the same filesystem it renames each entry. Across filesystems it copies each snapshot and session files directory to a staging name next to its destination, verifies every file byte for byte, renames the copy into place, and removes the sources only after every entry is published. It keeps permissions, modification times, symlinks, and the hard links snapshots share, and it updates the paths recorded in the database. It refuses a cold_root marked by another install and writes this install's marker. An interrupted run can be repeated; entries that already exist at the destination are verified against their source instead of copied again, and a mismatch stops the migration.
The command moves data only out of store_root. To move an existing cold_root elsewhere, stop Aperture and copy the whole tree, including .aperture-root, preserving hard links (for example rsync -aH).
On first aperture-server serve, the database is migrated and a local job token is created at $runtime_root/job-token (mode 0600). The GC timer uses aperture-server trigger gc, which reads that token and calls POST /internal/jobs/gc on the loopback listener.
Personal tenants
A personal tenant is a tenant owned by one user, named after them, in which they hold every tenant permission. It is private to that user:
- Nobody else can be a member, and the owner never changes.
- System administrators cannot list, select, rename or mint tokens for another user's personal tenant, and its audit events are hidden from them. To an administrator it does not exist; the user details page only shows whether the user has one.
- Only tenant tokens the owner created keep working in it.
Set allow_personal_tenants: false (APERTURE_ALLOW_PERSONAL_TENANTS=false) to forbid creating personal tenants. The account-menu item and the create buttons disappear, and the API answers personal_tenants_disabled. Existing personal tenants keep working, and their owners and administrators can still delete them.
Set auto_create_personal_tenant: true (APERTURE_AUTO_CREATE_PERSONAL_TENANT=true) to create one together with every new user: on OIDC first login with auto_provision, and by default when an administrator creates a user. The create-user form lets the administrator override the default per user. The user details page can create one later for a user who has none, or delete it, for example when offboarding, without revealing it.
Users manage their own personal tenant from Personal tenant in the account menu: create one or delete it. Deleting a personal tenant is final: nobody can restore it, and the owner can create a new one instead. A user owns at most one active personal tenant. Deleted tenants keep their owner for history. Disabling the user leaves the tenant in place.
A user without an explicit tenant selection lands in their personal tenant when they have one; otherwise the existing rule applies and a single membership is selected automatically.
The local aperture-server admin CLI works directly on the database and still sees every tenant.
User systemd services
Copy or link units from the package into ~/.config/systemd/user/ (the NixOS/Home Manager module does this automatically). Enable the core services:
systemctl --user daemon-reload
systemctl --user enable --now aperture@blue.service
systemctl --user enable --now aperture-gc.timer
systemctl --user enable --now aperture-traefik.servicebrowser-session@.service is started by Aperture per session; do not enable it directly.
Prepare Traefik runtime config before starting aperture-traefik.service:
mkdir -p "$XDG_RUNTIME_DIR/aperture/traefik"
cp "$(dirname "$(which aperture)")/../share/aperture/traefik/static.yaml.template" \
"$XDG_RUNTIME_DIR/aperture/traefik/static.yaml"
# Edit static.yaml: set entrypoints, certificates, and dynamic config watch path to
# $XDG_RUNTIME_DIR/aperture/traefik/dynamic.yaml (written by Aperture).Sudo helpers
Install the sudoers fragment as root (path from the package output):
sudo install -m 0440 share/aperture/sudoers/aperture-mount-helpers /etc/sudoers.d/aperture-mount-helpersEdit the file to substitute your login user for %aperture_user% and the store-path helper binaries for @mountSessionHelper@ / @unmountSessionHelper@.
Bootstrap and operation
aperture-server admin provision --admin-token-file ./admin-tokenThe command migrates the database, creates a default tenant when no active tenant exists, and writes the initial system-admin token with mode 0600. It is safe to run again; existing tokens and tenants are left unchanged.
Garbage collection is not scheduled inside aperture-server serve; enable aperture-gc.timer or run aperture-server trigger gc manually.
NixOS module
The flake exposes nixosModules.aperture at the flake root (not per-system). It configures a single login user with:
- the Aperture package
- generated
/etc/aperture/aperture.tomlsettings, or an external root-owned config file - blue/green API, browser session, optional Traefik, and garbage collection user units
- passwordless sudo for the packaged mount/unmount helpers
- the
aperture-rollouthealth-checked blue/green deployment helper
Import the module and set the required options:
imports = [ inputs.aperture.nixosModules.aperture ];
services.aperture = {
enable = true;
user = "alice";
externalBaseUrl = "https://browser.example.test";
storeRoot = "/srv/aperture";
# Optional: snapshots and session files on NFS, see Storage above.
coldRoot = "/mnt/aperture-cold";
settings = {
log_level = "info";
webrtc_media_mode = "auto";
webrtc_compositor_enabled = true;
};
environmentFile = "/home/alice/.config/aperture/aperture.env";
traefik.enable = true;
};The user must exist. Set createUser = true to let the module create it as a normal user with lingering enabled, so its user manager runs at boot without a login, in the render and video groups, and with a locked password. uid fixes its UID; the default null lets NixOS pick one, in which case runtimeRoot must be set, because its default /run/user/<uid>/aperture needs the UID at evaluation time:
services.aperture = {
user = "aperture";
createUser = true;
uid = 1000;
};storeRoot, coldRoot, and databasePath map to store_root, cold_root, and database_path; coldRoot defaults to storeRoot and databasePath to storeRoot/aperture.db. settings accepts non-secret Aperture TOML values. The module owns storage, runtime, deployment, public URL, and default Chromium channel fields so dedicated module options remain authoritative. Use configFile to replace the generated config entirely.
Keep credentials out of settings, because generated Nix files are readable from the Nix store. Put environment overrides in the file selected by environmentFile, with permissions limited to the Aperture user. For example:
APERTURE_WEBRTC_ICE_SERVERS='[{"urls":["turn:turn.example.test:3478"],"username":"aperture","credential":"..."}]'The deployment defaults are:
- blue API:
127.0.0.1:28080 - green API:
127.0.0.1:28082 - drain time: 30 seconds
- candidate health timeout: 30 seconds
Enable the edge proxy with services.aperture.traefik.enable = true; its default entrypoint is 127.0.0.1:28081. TLS and external ingress remain outside the module.
Enable Prometheus metrics with services.aperture.metrics.enable = true; they are served on 127.0.0.1:9464 by default. See Monitoring.
The module enables browser_pid_namespace. It works on bare NixOS and in a privileged Proxmox LXC container with nesting=1; set settings.browser_pid_namespace = false where bwrap cannot mount a new procfs.
On the first activation, reload the user manager, start blue, and make that instance persistent (or let deployment.autoRollout do it, see below):
systemctl --user daemon-reload
systemctl --user start aperture@blue.service
mkdir -p ~/.config/systemd/user/default.target.wants
rm -f ~/.config/systemd/user/aperture@blue.service
ln -sfn /etc/systemd/user/aperture@.service \
~/.config/systemd/user/default.target.wants/aperture@blue.service
systemctl --user daemon-reloadFor subsequent NixOS generations, reload the user manager and run aperture-rollout. The helper starts the inactive color, waits for /api/health, updates deployment state and Traefik routing, waits for the configured drain period, then stops the old API. A failed health check leaves the active color unchanged; a cutover error starts and restores the previous color.
Automatic rollout
deployment.autoRollout.enable = true does the steps above on every boot and activation through the aperture-deploy system unit. It runs as the Aperture user against its user manager, so user needs a fixed UID and lingering (createUser provides both). The unit:
- reloads the user manager
- when no color runs, enables and starts the color the last rollout left enabled, blue on a fresh install
- otherwise, when the Aperture package, the generated configuration, the API unit, or a path in
deployment.autoRollout.triggerschanged since its last run, runsaperture-rollout - enables and starts
aperture-traefik.serviceandaperture-gc.timerwhen they are enabled
The unit restarts only on activations that change one of those inputs. A failed rollout fails the unit and leaves the recorded state unchanged, so the rollout runs again when the unit next starts, on boot or on a later activation that changes an input. An external configFile, the environmentFile, and secret files are not tracked by content; list their sources in triggers, where a Nix path value is copied to the store so a change of its content counts:
services.aperture.deployment.autoRollout = {
enable = true;
triggers = [ ./secrets/aperture/oidc-client-secret ];
};WebRTC streaming
webrtc.enable = true sets up WebRTC streaming: it enables PipeWire, adds the flake's patched Weston and GStreamer to the system, points the Aperture services at the GStreamer plugins, and generates these settings:
- the Weston compositor (
webrtc.westonPackage, the flake'spatched-weston) with the PipeWire backend, the GL renderer, the Aperture shell, and a 1280x720 output - the GStreamer media producer streaming
weston.pipewireat 60 fps, 6000 kbps, and a keyframe every 120 frames recording_ffmpeg_executablefromwebrtc.ffmpegPackage, the flake'saperture-ffmpeg
The site-specific choices are options:
| Option | Default | Setting |
|---|---|---|
webrtc.advertisedIp | null (Aperture decides) | webrtc_media_producer_advertised_ip |
webrtc.udpPorts.from, webrtc.udpPorts.to | 50000, 50099 | webrtc_media_producer_udp_port_min, webrtc_media_producer_udp_port_max |
webrtc.codec | "h264-va" | webrtc_media_producer_codec |
webrtc.openFirewall | false | opens the UDP port range |
h264-va encodes through VA-API, so the host needs hardware.graphics with a VA-API driver for its GPU; use "vp8" to encode on the CPU. All generated values are defaults, so settings overrides any of them:
services.aperture = {
webrtc = {
enable = true;
advertisedIp = "203.0.113.10";
openFirewall = true;
};
settings.webrtc_compositor_width = 1920;
settings.webrtc_compositor_height = 1080;
};Verification
nix flake checkLive desktop smoke tests exercise the real app.Serve path, user systemd browser units, sudo-backed overlay mounts, and direct loopback CDP. They are gated behind APERTURE_LIVE_E2E=1 and do not start Traefik. Traefik/CDP edge routing is covered separately by APERTURE_LIVE_TRAEFIK=1 in internal/traefik/live_test.go.