workbench-nix gives each person persistent, isolated workspaces on NixOS. Each workspace is one long-lived cloud-hypervisor VM running a NixOS guest that the person owns and rebuilds. The person opens the workspace's apps from outside it:
- in the browser, each at
https://<workspace>--<app>.<domain>; - from their own terminal, over SSH through the front.
A person may have several workspaces.
workbench runs as a fleet of two roles:
- The front is what people reach, and it decides.
- Nodes run the workspaces' VMs and keep their disks.
One machine may have both roles: a host on its own is a front and a node. You plug a node in by declaring it. A workspace lives on one node until an admin moves it. docs/fleet.md shows a fleet at work, with the web UI's screens, and docs/multi-node.md has the whole design.
The fleet owns everything around the apps: the VM, its disk, network isolation, secrets, tools and memory. The apps are what the person opens from outside the workspace; see Apps.
workbench is built on vmkit-nix. Workspaces share a node with other vmkit controllers only through its guest networks and memory pools.
Every machine imports the module and the same fleet. The front enables
front, and each node enables node with its own name.
examples/fleet is a front and two nodes, each a
nixosConfiguration of its own; docs/fleet.md
walks through it.
{
inputs = {
vmkit.url = "github:OSSystems/vmkit-nix";
workbench = {
url = "github:OSSystems/workbench-nix";
inputs.vmkit.follows = "vmkit";
};
};
# in each machine's NixOS configuration
imports = [ inputs.workbench.nixosModules.default ./fleet.nix ];
}# fleet.nix: the same on the front and every node
{ pkgs, ... }:
{
services.workbench.fleet = {
domain = "ws.example.com"; # one wildcard certificate covers it
front.wireguard = {
address = "10.231.0.1";
publicKey = "…";
endpoint = "front.example.com:51820";
};
nodes = {
a = { subnet = "10.232.0"; wireguard = { address = "10.231.0.10"; publicKey = "…"; }; };
b = { subnet = "10.232.1"; wireguard = { address = "10.231.0.11"; publicKey = "…"; }; };
};
environment.ANTHROPIC_BASE_URL = "https://llm-proxy.example.com";
allowedEndpoints = [ { address = "10.0.5.20"; port = 443; } ]; # LLM proxy
extraPackages = [ pkgs.claude-code ];
workspaces = {
alice = { node = "a"; owner = "alice"; ip = "10.232.0.10"; };
alice-scratch = { node = "a"; owner = "alice"; ip = "10.232.0.11"; diskGiB = 128; };
bob = {
node = "b";
owner = "bob";
ip = "10.232.1.10";
environmentFile = "/run/secrets/bob-llm.env"; # a path on the front
};
carol = { node = "b"; owner = "carol"; ip = "10.232.1.11"; };
};
};
}# the front
services.workbench.front = {
enable = true;
virtualHost = { forceSSL = true; useACMEHost = "ws.example.com"; };
wireguard.privateKeyFile = "/run/secrets/wireguard";
admins = [ "alice" ];
oidc = { … }; # see Web UI below
};
# node b
services.workbench.node = {
enable = true;
name = "b";
network.externalInterface = "enp6s0";
wireguard.privateKeyFile = "/run/secrets/wireguard";
};A host on its own has both roles and one node. It reaches that node through sockets, so it needs no WireGuard and no keys.
services.workbench = {
fleet = {
domain = "ws.example.com";
nodes.a = { subnet = "10.232.0"; wireguard.address = "10.231.0.10"; };
workspaces.alice = { node = "a"; owner = "alice"; ip = "10.232.0.10"; };
};
front = { enable = true; virtualHost = { … }; oidc = { … }; };
node = { enable = true; name = "a"; network.externalInterface = "enp6s0"; };
};- WireGuard runs hub and spoke on
wg-workbench, UDP port 51820, infleet.wireguard.subnet(10.231.0.0/24by default). The front peers with every node on another machine and forwards nothing between them. A node peers with the front only and keeps the tunnel up, so the front needs no node's endpoint. The private keys are files given to the machines, such as sops secrets, readable bysystemd-network. The public keys are in the fleet (wg genkey | tee key | wg pubkey). - The front decides. Its registry,
/var/lib/workbench/registry, records who owns each workspace and which node it is on. The front also keeps the secrets directories, the SSH CAs and host keys, the devices and the quotas. When a node starts a workspace,workbench-frontanswers it with what the start needs: the secrets, a host key signed for<workspace>.<domain>, and the user CA. It answers only from the node's WireGuard address, and only for that node's workspaces. - A node runs workspaces.
workbench-nodemakes, starts, stops and deletes its workspaces and streams their disks; it answers the front's WireGuard address only. A node keeps the disks, the VM users and the taps. It holds a workspace's secrets only in its runtime directory while the workspace runs. If the front refuses a start or can't be reached, the node tries again every 10 seconds. - The front and the nodes are one build, deployed together. Each request between them carries the package's build, and a request from another build is refused.
- Placement: a workspace made at run time goes to the node an admin picks,
or else to the open node with the most free memory, and stays there.
Admins close and reopen nodes. They move a workspace made at run time
with
workbench move <workspace> <node>on the front, or from the host page. A declared workspace moves when itsnodeandipchange in Nix; the front moves its disk at the next deploy.
- The host becomes node
a. Itsnetwork.subnetbecomes the fleet'snodes.a.subnet, its workspaces getnode = "a", and the options move as docs/multi-node.md lists. Its VMs and disks stay. - A new machine becomes the front. It takes from the host, once:
- the SSH CAs and host keys (
/var/lib/workbench/ssh); - the quotas (
/var/lib/workbench/self-service/quotas); - the devices (
/var/lib/workbench-web/devices.json); - the secrets directories, with their sops secrets encrypted for it;
- the configs made at run time, as records on
a:workbench front import a <their copy>.
- the SSH CAs and host keys (
<domain>and*.<domain>point at the front.- Deploy both. A deploy restarts no VM. Each workspace asks the front at its next start, whenever that is, and is refused until the front has its record.
A host that stays on its own moves its options into fleet, enables
front and node on the same machine, and deploys. At that deploy,
workbench-front-setup makes a record, on its one node, of each workspace
it made at run time, from its config in /var/lib/workbench/configs. Their
owners keep their list rows, apps and SSH, and every workspace asks the
front at its next start. The host's CAs, host keys, quotas, devices,
secrets directories and stop markers stay where they are.
-
One unit per workspace.
workbench@<name>.serviceprepares the disk and the shares, starts virtiofsd, and then becomes cloud-hypervisor. The VM is the unit, not a daemon's child, so restarting or upgrading the memory daemon or the CLI never stops a VM. A deploy does not restart workspaces either: a new app or package set reaches a workspace at its next restart (workbench restart alice). Stopping a workspace presses its ACPI power button and waits for the guest to shut down.workbench stopkeeps it stopped across host reboots untilworkbench start. -
Declared in Nix, with no reconciler. On its node, each workspace is rendered to
/etc/workbench/<name>.jsonplus an instance of the template unit. On the front it is rendered to its record,/etc/workbench-front/<name>.json. The configs of workspaces made at run time are in/var/lib/workbench/configs, which/etcoverrides. Removing a workspace from the configuration stops its VM and keeps its disk in/var/lib/workbench/<name>on its node. Onlyworkbench destroydeletes the disk. -
The owner owns the guest.
fleet.image, a NixOS image, is converted into a persistent raw disk on first start and grown todiskGiB. The guest boots with the cloud-hypervisor UEFI firmware (OVMF-cloud-hypervisor,CLOUDHV.fd) and sets itself up from what the host shares; see The guest. The owner may change the guest freely, because the host enforces what matters for security. -
Tools come from the host, read-only. The guest gets only the closure of its packages and apps (
extraPackagesand the apps' bundles). Each path is bind-mounted in the unit's private mount namespace and served over virtiofs, so the guest never sees the rest of the host store. -
Secrets stay out of the store.
secretsDirdefaults to/var/lib/workbench-secrets/<name>on the front; fill it with sops-nix or similar. The front gives it to the node at every start, which copies it read-only to/run/workspace/secrets; none of it reaches the node's disk. The apps' secret environment is the directory'senvironmentfile, followed by the global and per-workspaceenvironmentFile(paths on the front). Theenvironmentoptions are the non-secret environment. -
Network. Each workspace has its own tap and a static
/32route in its node's subnet (fleet.nodes.<node>.subnet; the node is.1). Declared workspaces take.2to.127, and those made at run time take.128on. Guests reach the internet. They don't reach their node, private ranges, the WireGuard tunnel or each other, except for the global and per-workspaceallowedEndpoints. A guest can only send from its own address. nginx on the front proxies<workspace>--<app>.<domain>to the app's port in the guest, with websockets and day-long timeouts; for a node on another machine it goes through WireGuard. -
SSH by certificate. The front makes two SSH certificate authorities in
/var/lib/workbench/sshat its first boot:- The host CA signs each workspace's host key for
<workspace>.<domain>. The front keeps the key and gives it to the node at every start. - The user CA signs people's keys; the web UI uses it (see From a terminal). The guest's sshd trusts keys it signs, for the user they name.
Only the front and the guest's node reach a guest's port 22.
- The host CA signs each workspace's host key for
-
Memory. Workspaces boot with
fleet.memory.bootMiBand grow through virtio-mem up tofleet.memory.maxGiBunder pressure, with free page reporting.auto, there or in one workspace'smemory.maxGiB, means the node's memory, read at every start. Growth still stops short of the node'smemory.reservePercent, so a ceiling in GiB is what keeps one workspace from taking what the others would grow into. Wherefront.selfService.maxMemoryGiBisauto, workspaces made at run time may beautotoo, and new ones are unless their owner picks a size. Workspaces are afirstpool in vmkit'sservices.vmkit.memory.pools. On a node withyieldingpools, those pools only boot into and grow into memory that workspaces leave, apart from what each is guaranteed.
Day to day, on a workspace's node:
sudo workbench status
sudo workbench restart alice # with the fleet's apps and packages now
sudo workbench stop alice # stays stopped, also across reboots
sudo workbench start alice
sudo workbench console alice # serial console, Ctrl-] quits
sudo workbench destroy alice # a declared one: asks for the name, then deletes the diskA workspace made at run time belongs to the front. On its node, workbench destroy refuses it and says to run the command on the front. On the front:
sudo workbench destroy alice-dev # asks for the name, then deletes it: on its node, its
# disk, VM user and tap; here, its record, secrets
# and host key; refused while it moves
sudo workbench move alice-dev b # a workspace made at run time, to node b
sudo workbench forget alice-dev # one whose node is lost for goodOnly x86_64 machines are supported for now.
Every workspace is a NixOS system on its persistent disk, with its own
/nix/store and Nix daemon. The owner configures and rebuilds it like any
NixOS machine, and has sudo to do so. The host decides the network, the
secrets, the memory and the apps' versions, and enforces them whatever the
guest does. One module makes the system a workspace: the host's first
system imports it, and so does every system the owner builds.
Ubuntu guests, cloud-init and its seed disk are gone. So are the options that chose them:
| Removed | Now |
|---|---|
fleet.workspaces.<name>.os, .sudo |
gone |
front.selfService.os |
gone |
fleet.nixos.image |
fleet.image |
fleet.nixos.imageFormat |
fleet.imageFormat |
A workspace whose config or record says it is Ubuntu doesn't start. Its disk stays until it is destroyed.
The disk is made from fleet.image. By default that is a NixOS of the
host's nixpkgs with nixosModules.guest and nothing else. On a disk
without /etc/nixos/flake.nix, the guest creates the owner's account and
writes the flake it is rebuilt from:
# /etc/nixos/flake.nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
workbench = {
url = "github:OSSystems/workbench-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ nixpkgs, workbench, ... }:
{
nixosConfigurations."carol" = nixpkgs.lib.nixosSystem {
modules = [
workbench.nixosModules.guest
./configuration.nix
];
};
};
}# /etc/nixos/configuration.nix
{ pkgs, ... }:
{
nixpkgs.hostPlatform = "x86_64-linux";
users.users."carol" = {
isNormalUser = true;
extraGroups = [ "wheel" ];
# The user manager runs from boot, for the workspace's apps.
linger = true;
};
environment.systemPackages = with pkgs; [ git vim ];
system.stateVersion = "26.05";
}The owner edits /etc/nixos, keeps it in git if they like, and runs:
sudo nixos-rebuild switch # builds the configuration named after the host
cd /etc/nixos && sudo nix flake update && sudo nixos-rebuild switchThe guest fetches its inputs and substitutes or builds its packages
itself, over the internet. Its memory grows for the build like for any
other load. A rebuilt system is also the next boot's system; the guest
never writes /etc/nixos again.
systemd-boot keeps the previous generations. To start one after a bad
rebuild, attach workbench console <name> on its node, or open its console
in the web UI, and restart the workspace. The menu waits
boot.loader.timeout, one second by default.
At every boot, the module:
- boots from the disk: systemd-boot on the ESP, the root file system grown
to the disk, the serial console on
ttyS0; - mounts, all read-only, the config share at
/run/workspace/config, the secrets share at/run/workspace/secretsand the host's closure at/run/workspace/host/nix/store; - configures the address, the route through the host, DNS and the hostname
from
workspace.json, with systemd-networkd; - copies into
/nix/storethe paths of the packages' and apps' closure that the store lacks, registers them, and keeps them alive with the GC roots/nix/var/nix/gcroots/workspace-app,workspace-app-<id>andworkspace-agent(the agent also makes these as it starts, for guests set up with an oldernixosModules.guest); - creates the owner's account in
wheelif it does not exist yet, lets it linger unless the system's configuration says otherwise, and writes/etc/nixoson a new disk; - lets sshd read the owner's keys from the config share, serve the host's key for the workspace and trust the host's user CA, with passwords off;
- starts
workspace-agent.service, which reports memory, makes sign-in links, and runs each app asworkspace-app-<id>.service, as the owner, with the workspace's environment; - prepends the host's tools (
extraPackagesand the apps' packages) to every shell'sPATH, including commands over SSH, for which bash reads/etc/set-environment; - lets
wheelrunwb-thread-execas root, writes/etc/wb/threadsand links/etc/t3code/policy.jsonto the host's, for T3 Code's threads; - leaves the guest firewall off, enables flakes, and lets
wheeluse sudo without a password.
The settings the module marks as defaults are the owner's to override: the firewall, sudo, SSH passwords and the boot loader timeout. The host relies on the rest.
workbench.nixosModules.guestamong the flake's modules. Without it, the next boot has no network, apps or memory reports. The host's isolation does not depend on it: a guest without it is a VM that reaches nothing it could not reach before.- Their account. The module adds one at boot if it is missing, which needs
users.mutableUsers(NixOS's default). With immutable users, declare the account, as the generated configuration does. - The file systems and boot loader the module sets, unless the owner replaces the disk layout with one that boots the same way.
The guest's store is its own, so the host cannot mount its closure there:
a path the next closure drops would stay registered without its files.
Instead, every boot copies the paths the guest lacks from
/run/workspace/host/nix/store. The first boot, and the first boot after a
new app or extraPackages, takes as long as that copy. Each workspace keeps
the closure on its disk: about 3 GiB for T3 Code and the agents it runs,
which counts against diskGiB. Old versions go when the owner collects
garbage.
The host decides the apps' versions. The owner decides the system's,
including the version of nixosModules.guest, through the flake's
workbench input. The table below lists what the module reads from the
host. It changes with care, so a guest a few releases behind keeps working.
| Path in the guest | What |
|---|---|
/run/workspace/config/workspace.json |
name, owner, url, ip, gateway, nameservers, appPort, controlPort, agentPort, apps |
/run/workspace/config/app |
The packages: sw/bin holds extraPackages and the apps' packages; bin/workspace-agent starts the agent |
/run/workspace/config/app/threads |
wb-thread-exec, the shell and agents T3 Code runs through it, and T3 Code's policy |
/run/workspace/config/agent |
The agent, bin/workspace-agent, the host's workbench |
/run/workspace/config/apps/<id> |
An app's bundle: bin/serve, and bin/open-link if it signs browsers in |
/run/workspace/config/environment |
The non-secret environment, for systemd's EnvironmentFile= |
/run/workspace/config/authorized_keys/<owner> |
The owner's SSH keys |
/run/workspace/config/ssh/user-ca.pub |
The host's user CA, which sshd trusts for the owner |
/run/workspace/config/ssh/principals/<owner> |
The owner's name, the one principal sshd takes from a certificate |
/run/workspace/config/store-paths, registration |
The closure's paths, and their validity for nix-store --load-db |
/run/workspace/secrets |
The secrets directory; its environment file is the app's secret environment |
/run/workspace/secrets/ssh-host |
The workspace's SSH host key, root's, and its certificate from the host CA |
the store share |
The app's closure, at /run/workspace/host/nix/store |
| vsock | The agent reports memory to the host on controlPort and answers it on agentPort |
The front serves a web UI at https://<domain> and puts single sign-on in
front of every workspace. Whatever the app does about accounts, only the
workspace's owner and the admins reach it. People see and control their own
workspaces: they open their apps, set up their computers to reach them from
a terminal, start, stop and restart them, and use the serial console.
Admins see all workspaces and every node's memory.
services.workbench.front = {
enable = true;
admins = [ "alice" ];
oidc = {
issuerUrl = "https://sso.example.com/realms/example";
clientId = "workbench";
clientSecretFile = "/run/secrets/workbench-oidc";
cookieSecretFile = "/run/secrets/workbench-cookie"; # openssl rand -hex 16
};
};The identity provider is Keycloak by default. It needs:
- a confidential OIDC client with the redirect URI
https://<domain>/oauth2/callback; - a
preferred_usernameclaim that is the LDAP uid workspaces have asowner; - a
groupsclaim, which gives the roles below.
One virtual host serves every workspace, so the certificate must be a
wildcard for *.<domain> as well as cover <domain>. Give it through
virtualHost, such as useACMEHost.
With front.selfService, members of its groups make their own workspaces
in the UI, within a quota that admins change there, and destroy them:
services.workbench.front = {
adminGroups = [ "workbench-admins" ];
selfService = {
enable = true;
groups = [ "workbench" ];
# Prints an owner's secret environment (the app's credential);
# failing or printing nothing refuses the request.
environmentCommand = "/path/to/workspace-env";
# Exit 0 while an owner stays, 1 once they leave the group or directory;
# the timer then stops their workspaces and keeps the disks.
ownerCommand = "/path/to/workspace-owner";
};
};The UI stays unprivileged: it only writes the request.
workbench-create@<ws>.service on the front places the workspace and has
its node make it as root, with its VM user as a userdb record and its tap
as systemd-networkd files.
The UI is workbench-web, a Leptos app in Rust. The server renders the
pages, and the browser hydrates them with the same components compiled to
WebAssembly. It runs on the front as its own user, on top of the registry
and the nodes' APIs, which start, stop and restart the VMs and share their
consoles. polkit lets it start only the front's units that make, change,
move and destroy workspaces. docs/web-ui.md has the whole
design.
An app is what runs in a workspace and is opened from outside it:
- in the browser, at
https://<workspace>--<app>.<domain>, an origin of its own; - for an app without an address, from a terminal on the person's own computer, over SSH through the front.
The fleet offers apps in services.workbench.fleet.apps. Each workspace
has the ones its apps names. When it doesn't set apps, it has those
whose default is true. A workspace may have no apps.
https://<workspace>.<domain> leads to the workspace's panel in the web
UI.
services.workbench.fleet.apps.notes = {
name = "Notes";
port = 8080;
packages = [ pkgs.mynotes ];
# Run as the owner at every boot; systemd restarts it when it ends.
serve = ''exec mynotes --listen 0.0.0.0:"$APP_PORT"'';
};The guest agent runs each app's serve at every boot as
workspace-app-<id>.service, as the owner, with the workspace's
environment and secrets. A VM keeps the apps it booted with. A change to
them, or a new version, comes with its next restart, and the web UI says
what is waiting for it.
| Option | Effect |
|---|---|
port = null |
An app without an address. nginx reaches nothing of it, and its panel has Connect… instead of Open, with the steps of its connect. |
default = false |
An app people opt into. A workspace has it when its apps names it, and the New workspace form leaves it unticked. |
oneshot = true |
serve starts what the app runs and ends, such as services of the owner's user manager, which runs from boot. Its unit stays active and is never restarted. |
T3 Code is the app t3code when
fleet.package is set. By default it is set to the t3code-server of
t3code-nix, which is T3 Code
with OSSystems' patches. The agents of
llm-agents.nix are on its
PATH; workbench's other AI tools come from there too.
The app runs t3 serve on port 3773. T3 Code has no accounts: a browser
gets in by following a one-time pairing link, made for the owner inside the
guest. The module gives the app the sign-in hook,
around t3 auth pairing create.
T3 Code's desktop and phone apps reach it too, with nothing else to
install. They can't use single sign-on, so the front lets through what
T3 Code checks itself: its bearer tokens and WebSocket tickets, and the
discovery and token exchange before them (see nativeClients below). In
the web UI, the app's ⋯ menu has two entries:
- Open in T3 Code desktop hands the desktop app a fresh link.
- Open on another device… shows a QR code for the phone to scan.
T3 Code caps its agents' memory at a share of the machine's RAM when an
agent starts. A workspace boots with its boot memory and grows on demand up
to its maximum, so that cap would stop agents long before the VM's own
limit. The app therefore runs with
T3CODE_AGENT_SLICE_MEMORY_POLICY=host-managed, one of t3code-nix's
patches, and the VM's maximum is the only cap.
Each T3 Code thread runs in an Ubuntu 24.04 root of its own, through
wb-thread-exec. A thread can sudo apt install what it needs without
waiting for another thread's apt or removing what another uses. That
includes a package that conflicts with another thread's, as
libcurl4-openssl-dev does with libcurl4-gnutls-dev.
The root is an overlay, on the guest's disk, of fleet.threads.base. By
default the base is an Ubuntu 24.04 with apt, sudo, git, curl,
build-essential and python3 that starts no service. The root shares the
guest's /home, /nix/store, /tmp, /proc, /sys, /dev, /run/user
and /run/workspace. What a thread installs is its own; what it writes in
the owner's home is everyone's.
Threads keep packages apart, not people: the VM is still the boundary.
Threads share the guest's network, processes and memory, so T3 Code still
finds their servers, caps their agents and stops them. Threads are always
on; fleet.threads.enable is gone.
In a thread's root, the base's own accounts stay and the owner joins them:
- the base's
useraddadds the owner, with their primary group and those of their groups the base has; /etc/sudoers.d/90-workbenchgives them sudo without a password;- a login shell the base lacks, such as NixOS's
/run/current-system/sw/bin/bash, becomes/bin/bash.
T3 Code's terminals and project scripts run in their thread's root through
wb-shell (wb-thread-exec --shell), which runs the login shell the root's
accounts name. T3 Code's claude and codex go through wb-claude and
wb-codex. T3 Code's managed policy, /etc/t3code/policy.json, points it
at them, and its settings say "Managed by workbench".
Not everything T3 Code runs is in a thread:
- Cursor, OpenCode and Grok run on the NixOS guest itself, without apt.
T3 Code 0.1.11 runs Cursor in its own process (
@cursor/sdk), OpenCode as one server for all threads, and Grok without the thread's id, so no shim can put them in a thread. - T3 Code's own Commit and Push run
git commitfrom its server, outside any thread, so a hook that needs a tool installed in a thread fails there. An agent's own commits run in its thread.
SSH into the workspace lands on NixOS, where nothing a thread installed is
present. To open a thread's root from a terminal in the guest, run
T3CODE_THREAD_ID=<thread> /run/workspace/config/app/threads/bin/wb-thread-exec bash.
A thread keeps the base it started with, in the guest, when the host has a
newer one; new threads start from the newer base. T3 Code says nothing when
it deletes a thread. So when a new thread starts, any thread not entered
for 30 days, nor since the guest booted, loses its root, and a base that no
thread is on goes too. The base is built in a VM, on a machine with the
kvm system feature.
nixosModules.guest gives wheel the sudo rule wb-thread-exec needs,
writes /etc/wb/threads, and links /etc/t3code/policy.json to the host's
policy. A workspace made before the module did this takes it up when its
owner updates the workbench input of /etc/nixos and rebuilds:
cd /etc/nixos && sudo nix flake update workbench && sudo nixos-rebuild switchUntil then, its threads' commands run on the VM itself.
herdr has two runtimes. Both are apps without an address that workspaces opt into, and both come from llm-agents.nix too.
| App | What runs in the workspace | From the person's computer |
|---|---|---|
herdr, Herdr |
the TUI's server, herdr server, in the foreground |
herdr --remote <workspace>.<domain> |
herdrcore, Herdr app |
herdr-core's core, which hc server start starts as a user service |
herdr-app: Add machine, <workspace>.<domain>; or hc machine add <workspace>.<domain> |
services.workbench.fleet.workspaces.alice.apps = [ "t3code" "herdr" "herdrcore" ];Their panes and terminals have the workspace's environment and secrets.
Herdr's server has them as any app does. Herdr app imports them into the
owner's user manager before it starts the core, whose terminals are user
services. Both find themselves over SSH on the workspace's PATH, and
herdr update and hc update say that a newer version comes with the
host. fleet.herdr.package and fleet.herdrCore.package choose the
versions.
People reach a workspace's SSH server from their own computer. They register no key and need no port but the host's HTTPS.
-
A workspace's Connect… page, behind single sign-on, shows a command with a code. The code works once, for 10 minutes, for the person signed in:
curl -fsSL https://<domain>/connect/install.sh | sh -s -- <code>
-
The command downloads
workbench-connect, a static binary for x86_64 or aarch64 Linux. It installs itself in~/.local/binand trades the code for a credential for that computer. The credential works for 30 days, as long as the person signs in to the UI at least every 7. It writes~/.config/workbenchand includes itsssh_configat the top of~/.ssh/config. -
ssh <workspace>.<domain>then signs in as the person.workbench-connectgets the computer's key signed for them for 8 hours. It is also theProxyCommand: a WebSocket to the host, which lets it through to the workspace's port 22 if the workspace is theirs and running. The host CA vouches for the workspace's host key.
/devices, in the user's menu, lists a person's computers and revokes
them. docs/web-ui.md has the whole design.
An app may have openLink, a script the agent runs when someone opens the
app from the web UI. The agent runs it as the owner, with the app's address
in APP_URL. The script prints one URL on the app's own origin that signs
a browser in, and nothing else on stdout. workbench open-link prints that
URL:
sudo workbench open-link alice t3codeAn app without the hook is opened at its address.
Some apps with the hook also have clients of their own that can't use
single sign-on, such as a desktop or phone app. Such an app says in
nativeClients what those clients reach it with:
pathsreached before there is a credential;headersandqueryparameters that carry a credential.
The front lets those requests through without single sign-on, and the
app's own sign-in is then all that guards them. desktop gives the web UI
an Open in entry for the desktop app: an address in which @link@ stands
for the hook's link. The module sets T3 Code's:
services.workbench.fleet.apps.t3code.nativeClients = {
paths = [ "/.well-known/t3/environment" "/oauth/token" ];
headers = [ "authorization" ];
query = [ "wsTicket" ];
desktop = { name = "T3 Code desktop"; link = "t3code://pair?pairingUrl=@link@"; };
};nix develop # cargo, clippy, rustfmt, rust-analyzer, lld, wasm-bindgen; links ./vmkit
cargo test --workspace
cargo test -p workbench-web --features ssr
nix build .#web .#web.site # the UI's server, and its WebAssembly and assets
nix build .#workbench-connect .#workbench-connect.aarch64-linux # the client, static
(cd connect && cargo test) # the client, a crate of its own
nix flake check # rustfmt, clippy, the tests, the module evaluations and the VM tests
nix fmt -- $(git ls-files '*.nix')workbench is a Rust crate built against the vmkit crate of the flake's
vmkit input. That is the same revision whose NixOS module the host
imports, so a host whose vmkit input follows its own builds workbench
against that one. Cargo.toml takes vmkit from ./vmkit, which
nix develop links to the locked input and the package copies in. vmkit's
dependencies are locked in Cargo.lock with workbench's. To work on both
at once, link ./vmkit to your own vmkit checkout; nix develop leaves
such a link alone.
docs/contracts.md describes what the host and its
guests exchange: workspace.json and the agent's requests.
workbench-connect, in connect/, has a Cargo.lock of its own and no
dependency on workbench's crates or vmkit. Its aarch64 build cross-compiles
Rust's standard library for musl, which no binary cache has, so the first
build of the front takes a while longer.
| Check | What it does |
|---|---|
checks.guest |
Evaluates the system a new workspace writes and rebuilds. |
checks.fleet, checks.shared-host |
Evaluate what the modules render for a front, a node and both, and their assertions. |
checks.workspaces |
Boots two workspaces in a NixOS VM test on a host on its own, each with T3 Code and herdr's two runtimes. |
checks.multi-node |
Boots a front and two nodes over WireGuard, makes a workspace and moves it between them. A client uses the web UI across them: an app and the SSH tunnel to a node's guest, an admin's node pick, Close and Move, and a node that doesn't answer. |
checks.threads |
Boots a workspace whose T3 threads have roots of their own, and installs conflicting packages in two of them. |
The three VM tests need nested virtualization on the machine that builds
them (kvm_amd/kvm_intel with nested=1). checks.workspaces runs the
default app, T3 Code, from t3code-nix, which OSSystems' Garnix builds and
caches. A machine without that cache among its substituters builds it.