muelle
Pull-based CI/CD for static sites on a NixOS host.
GitHub Actions builds the site and uploads it as a workflow artifact. The muelle composite action sends an HMAC-signed request to the host; the host fetches the artifact, verifies it and flips a symlink. CI never gets shell access and never applies NixOS configuration: the NixOS module is the only authority on which sites, environments and paths exist.
Status: prototype. Static sites only.
sequenceDiagram
participant CI as GitHub Actions
participant W as webhook (host)
participant R as muelle-receive
participant K as muelle-worker
CI->>CI: build, upload-artifact
CI->>W: POST /hooks/#lt;site#gt; (HMAC-signed)
W->>W: check HMAC
W->>R: payload
R->>R: validate against the Nix site table, spool
R-->>K: detach worker
R-->>CI: {id, url} (through webhook)
K->>K: download artifact (GITHUB_TOKEN), check sha256
K->>K: extract, flip current, prune
loop until success or failure
CI->>W: GET /status/#lt;id#gt;
W-->>CI: status file
end
CI->>CI: set GitHub Deployment state
Where to start
- Host setup and Your first workflow get a site deployed.
- The guides cover environments, gating previews, the listing, operating the host and migrating an existing site.
- Architecture and Security model explain why it works the way it does.
- The reference is generated from its sources: NixOS options, action inputs, admin CLI and the Python modules.
Not yet
- Uploading the artifact in the request body (fallback when the token cannot fetch it).
- Node/JVM apps, WordPress.
- Marking GitHub deployments inactive on teardown.
Host setup
Add the flake and its module to your NixOS configuration:
{
inputs.muelle.url = "github:haztecaso/muelle";
# in your nixosConfiguration modules: inputs.muelle.nixosModules.default
}
Then declare the muelle domain and your sites:
{ config, ... }:
{
services.muelle = {
enable = true;
domain = "muelle.example.com"; # hooks, status, listing; previews at *.muelle.example.com
acmeHost = "example.com"; # cert covering muelle.example.com and *.muelle.example.com
previewVhost = { }; # e.g. { enableAuth = true; } for your own auth gate
sites.mysite = {
repo = "octocat/mysite";
secretFile = config.age.secrets."muelle-mysite".path;
# muelle declares the prod vhost: HTTPS, root, try_files, per-site logs
domain = "mysite.example.org"; # prodUrl defaults to https://<domain>
acmeHost = "mysite.example.org"; # default: domain
extraConfig = ''
error_page 404 /404.html;
'';
previewApex = "mysite.example.org"; # next.<apex>, <hash>.<apex> 302 to the gated previews
# publicPreviews = true; # or serve them there, ungated
};
};
# extend the prod vhost by name when extraConfig is not enough
services.nginx.virtualHosts."mysite.example.org".locations."/feed".proxyPass = "http://127.0.0.1:8000";
}
Without domain, muelle declares no prod vhost: set prodUrl and point
your own vhost at services.muelle.sites.<name>.root.
accessLogFormat picks a log_format (defined elsewhere) for the prod
access logs. Every option is listed in the NixOS options
reference.
domain also serves a listing of every next and preview environment, which
reveals branch names: gate it before going further, see
Gating previews.
The secret
Generate one secret per site, as hex (it is embedded in the webhook config template):
openssl rand -hex 32
Store it on the host (e.g. with agenix, as secretFile) and as a repository
secret (MUELLE_SECRET) on GitHub. A secret only works on its own site’s hook.
Next: Your first workflow.
Your first workflow
muelle is a composite action: add it as a step after
actions/upload-artifact. This workflow deploys main to prod, next to
next and every other branch to a preview, and removes a branch’s previews
when the branch is deleted:
name: deploy
on:
push:
branches: ["**"]
delete:
jobs:
deploy:
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
actions: read # lets the host download the artifact with this job's token
contents: read
deployments: write # GitHub Deployment status (disable with `deployments: false`)
steps:
- uses: actions/checkout@v4
- run: make build # produces ./dist
- id: upload
uses: actions/upload-artifact@v4
with:
name: site
path: dist
retention-days: 1
- uses: haztecaso/muelle@<sha> # v3.2.0
with:
endpoint: https://muelle.example.com
site: mysite
secret: ${{ secrets.MUELLE_SECRET }}
environment: ${{ github.ref_name == 'main' && 'prod' || github.ref_name == 'next' && 'next' || 'preview' }}
artifact-id: ${{ steps.upload.outputs.artifact-id }}
artifact-digest: ${{ steps.upload.outputs.artifact-digest }}
teardown:
if: github.event_name == 'delete' && github.event.ref_type == 'branch'
runs-on: ubuntu-latest
permissions:
deployments: write
steps:
- uses: haztecaso/muelle@<sha> # v3.2.0
with:
endpoint: https://muelle.example.com
site: mysite
secret: ${{ secrets.MUELLE_SECRET }}
action: teardown
Replace <sha> with the commit of a release, see
Versioning and pinning the action.
The deploy step waits until the host has deployed (or failed) and sets the
step output url and the GitHub Deployment state. The job’s token stays valid
while the action waits for the host, which is what lets the host download the
artifact with it.
A zip artifact with a single top-level directory is unwrapped, so uploading
dist/ or its contents both work.
Endpoint
endpoint must be https://: the request body carries the job’s token.
Plain http:// is accepted only for loopback hosts, or anywhere with
MUELLE_ALLOW_INSECURE=true in the job’s environment.
Outside GitHub Actions
The action’s logic lives in
src/muelle/client.py
(stdlib only, run on Python 3.14 from actions/setup-python without touching
the job’s PATH), which the NixOS VM test runs against a real host. It also
works outside GitHub Actions as muelle-client, configured through MUELLE_*
environment variables (see muelle.client);
set SSL_CERT_FILE to trust a private CA.
Next: list builds while they run with announce and abort, or read about environments.
Environments and URLs
Each site has up to three environments:
| env | URL |
|---|---|
prod | https://<sites.<name>.domain> (vhost declared by muelle), or your own vhost rooted at services.muelle.sites.<name>.root |
next | https://next-<site>.<domain> |
preview | https://<hash>-<site>.<domain> (new URL per commit) |
envs = [ "prod" ] disables next and previews for a site.
domain is the single host muelle answers on: /hooks/<site> and
/status/<id> for CI, and /, which lists every deployed next and preview
environment (also as index.json) and the jobs in progress or recently
failed (see Following deploys in the listing). The listing
reveals branch names and URLs, so gate it: see Gating previews.
Slots
On disk, each environment is a slot:
<baseDir>/<site>/<slot>/releases/<sha> plus a current symlink that a
deploy flips atomically. Slots are prod, next, and an 8-hex hash of
site + branch + sha per preview.
Under the site’s own domain
With previewApex = "example.com", next.example.com and
<hash>.example.com 302 to <slot>-<site>.<domain>, so previews can be
reached under the site’s own domain, behind the same gate.
Add publicPreviews = true to serve them there instead, without
previewVhost: next.example.com and <hash>.example.com are public, and
CI, the listing and the admin CLI report those URLs.
<slot>-<site>.<domain> keeps its gate. Previews then share a site with
prod: read Gating previews first.
previewApex needs an ACME cert of the same name covering *.<apex>.
Caching hashed assets
Build tools put a content hash in the names of their assets (Astro under
/_astro/, Vite under /assets/): a changed file gets a new URL. List
those prefixes in immutablePaths and prod, next and previews send them
with Cache-Control: public, max-age=31536000, immutable, so browsers keep
them a year without revalidating:
services.muelle.sites.mysite.immutablePaths = [ "/_astro/" ];
Everything else keeps nginx’s ETag and Last-Modified revalidation, and a
404 under those prefixes is not cached. Never list a path whose files
change in place.
Branch policy
Only the branches in prodBranches (default [ "main" ]) may deploy to
prod; null lets any branch. Sites that deploy prod from tags need
prodBranches = null for now, since tag names are not branches.
The branch comes from the HMAC-signed payload, which the workflow builds. So
prodBranches catches mistakes (a wrong workflow expression, a feature
branch deploying to prod), not a leaked secret: whoever holds the secret can
sign any branch name. It becomes a real boundary once the host can verify
the branch itself (GitHub OIDC,
#12).
Pruning
- Each slot keeps
keepReleases(3) releases, never removing the onecurrentpoints to. - Previews are removed when a site has more than
keepPreviews(10). muelle-prune.timerremoves previews daily (or on demand withmuelle prune) once their last deploy is older thanpreviewTtlDays(30, per sitesites.<name>.previewTtlDays; null disables).- Deleting a branch removes its previews if the workflow has a teardown job, as in Your first workflow.
Gating previews
next and every preview serve whatever a branch built, and the listing at /
of domain reveals branch names and URLs. Gate both.
Where to put the gate
previewVhost: aservices.nginx.virtualHosts.<name>module merged into every next/preview vhost and into thedomainvhost (the listing), e.g. an auth gate:previewVhost = { enableAuth = true; };with your own auth module, or{ basicAuthFile = "/run/secrets/htpasswd"; }.sites.<name>.previewVhost: added to one site’s next/preview vhost.indexVhost: added to thedomainvhost only.
Gate location / only: /hooks/ and /status/ are separate locations and
must stay reachable from CI. Modules in the style of enableAuth that set
up location / do this already.
Preview isolation
next and every preview serve content from any branch, and they all live
under *.<domain>: same-site with each other, with /status/ and with the
listing. Treat their content as untrusted:
- A preview’s JavaScript can set cookies for
<domain>(cookie tossing), e.g. to interfere with an auth gate’s session. - If that gate scopes its cookie to
.<domain>(single sign-on across previews), every preview makes credentialed same-site requests to every other preview and to the listing.
So:
- Gate next and previews (
previewVhost). - Use host-only cookies for the gate (no
Domainattribute), so each preview signs in on its own. - If you deploy branches from people you do not trust, serve
domainfrom its own registrable domain (one that hosts nothing else, like GitHub Pages and Netlify do with their public-suffix domains), so previews cannot reach cookies or same-site requests of your other hosts.
Public previews
publicPreviews = true serves a site’s next and previews on
next.<previewApex> and <hash>.<previewApex>, without previewVhost
(see Environments and URLs).
Anyone with the URL can open them, and their content shares a site with
prod: a preview’s JavaScript can set cookies for .<previewApex> and make
same-site requests to prod. Turn it on only when every branch that deploys
comes from people you trust and prod keeps no session or cookies a
preview could abuse. next.<previewApex> is easy to guess; a preview’s
hash is not. They are sent with X-Robots-Tag: noindex, nofollow.
The listing stays behind previewVhost and indexVhost.
Since previewVhost is not merged there, the site’s own nginx settings for
these vhosts go in publicPreviewVhost, for example its 404 page:
services.muelle.sites.mysite = {
extraConfig = "error_page 404 /404.html;"; # prod
previewVhost.extraConfig = "error_page 404 /404.html;"; # <slot>-mysite.<domain>
publicPreviewVhost.extraConfig = "error_page 404 /404.html;"; # next/<hash>.<previewApex>
};
A Content-Security-Policy for prod, next and previews is the site’s
business; muelle only sets one on the listing and /status/ (see
Security model).
Following deploys in the listing
The listing at / of domain (and /index.json) shows, per site, the
deployed next and preview environments and, above them, the jobs of every
env (prod included) that are building in CI, deploying, or failed in the
last 7 days, each linked to its GitHub Actions run.
Announce and abort
The host only hears of a deploy once the build is done, so on its own the listing shows a job from the deploy request on, which is seconds before it succeeds. Two optional steps cover the build itself:
action: announce, first in the job, lists the env and branch as building, linked to the run.action: abort, last, withif: failure() || cancelled(), lists it as failed when the run ends before the deploy step got anywhere.
Neither waits for the host, and both only warn when it cannot be reached or
rejects them (an older host answers invalid action), so they never fail a
build.
abort is ignored unless the newest job for that env and branch is still
the announce of the same run (same sha and run_url). It changes nothing
when a deploy of the same run already reached the host, so a host-side
deploy failure keeps its own message.
The deploy request carries the run’s URL too, so deployed environments link to the run that deployed them.
jobs:
deploy:
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
deployments: write
env:
ENVIRONMENT: ${{ github.ref_name == 'main' && 'prod' || github.ref_name == 'next' && 'next' || 'preview' }}
steps:
- uses: haztecaso/muelle@<sha> # v3.2.0
with:
endpoint: https://muelle.example.com
site: mysite
secret: ${{ secrets.MUELLE_SECRET }}
environment: ${{ env.ENVIRONMENT }}
action: announce
- uses: actions/checkout@v4
- run: make build # produces ./dist
- id: upload
uses: actions/upload-artifact@v4
with:
name: site
path: dist
retention-days: 1
- uses: haztecaso/muelle@<sha> # v3.2.0
with:
endpoint: https://muelle.example.com
site: mysite
secret: ${{ secrets.MUELLE_SECRET }}
environment: ${{ env.ENVIRONMENT }}
artifact-id: ${{ steps.upload.outputs.artifact-id }}
artifact-digest: ${{ steps.upload.outputs.artifact-digest }}
- if: failure() || cancelled()
uses: haztecaso/muelle@<sha> # v3.2.0
with:
endpoint: https://muelle.example.com
site: mysite
secret: ${{ secrets.MUELLE_SECRET }}
environment: ${{ env.ENVIRONMENT }}
action: abort
Which job is shown
Per site, the listing shows the newest job of each (site, env) for prod
and next, and of each (site, env, branch) for previews:
- while it is queued or in progress, for up to an hour (longer means a run that vanished without abort, or a killed worker);
- when it failed, for 7 days.
A newer job, such as a successful deploy or a teardown of the branch, replaces it.
While a job is pending, the page reloads every 15 seconds. The listing is
static: it is regenerated on each hook request and at least daily (by
muelle-prune.timer), so a pending job past its hour can linger until then.
muelle index regenerates it on demand.
The fields of index.json are in Files on the host.
Operating the host
Admin CLI
The module installs muelle for operations that should not depend on CI.
It uses the module’s config and the worker’s locks, and runs as the muelle
user (through runuser as root, sudo -u muelle otherwise).
muelle status [<site>] # slots, current release, deploy date, URL
muelle releases <site> <slot> # kept releases of prod, next or a preview (* = current)
muelle prune [<site>] # apply previewTtlDays, keepPreviews, keepReleases now
muelle teardown <site> <branch> # remove every preview of a branch
muelle rm <site> <slot> # remove next or one preview (never prod)
muelle index # rebuild the listing
muelle jobs [<site>] [-n 20] # recent jobs (hook requests and host actions)
muelle log <id> # a job's log
Every command and flag is in the Admin CLI reference.
Jobs
Every hook request is a job, identified by the id of its payload. prune,
teardown and rm are recorded the same way, as a host-... job with
status file and log, and refresh the listing. muelle jobs lists both
kinds, newest first, and muelle log <id> prints a job’s log, which holds
the detail and traceback of failures that /status/<id> reports only as
internal error.
Timers
muelle-prune.timer runs the same pruning as muelle prune daily (as
muelle prune --no-record, so it leaves no job behind) and regenerates the
listing.
Where things live
Under baseDir (/var/www/muelle), served by nginx:
<site>/<slot>/releases/<sha>/ one release per deployed commit
<site>/<slot>/current symlink to the live release
<site>/<slot>/meta.json last deploy of the slot
Under stateDir (/var/lib/muelle):
| path | served | content |
|---|---|---|
status/<id>.json | yes, /status/<id> | state of a job, polled by CI |
index/ | yes, / | the listing (index.html, index.json) |
jobs/<id>.json | no | site, action, env, branch of a job |
log/<id>.log | no | a job’s log |
spool/ | no | payloads waiting for the worker (mode 0700, holds tokens) |
locks/ | no | per-site and listing locks shared by worker and CLI |
status/, jobs/ and log/ are cleaned by systemd-tmpfiles after 30 days.
/status/<id> is public, so it deliberately carries no branch names: those
stay in jobs/. The schemas are in Files on the host.
Migrating an existing site
Seed the first release from the current docroot without copying data
(hard links, same filesystem), then set domain (or point your vhost at
.root):
site=mysite; old=/var/www/mysite
base=/var/www/muelle/$site/prod
sudo install -d -o muelle -g muelle "$base/releases"
sudo cp -al "$old" "$base/releases/initial"
sudo chown -R muelle:muelle "$base/releases/initial" # also changes owner of $old's inodes
sudo -u muelle ln -sfn releases/initial "$base/current"
Content that is not produced by the site build (archives, uploads) disappears on the next deploy; serve it from a separate path.
Versioning and pinning the action
The action is released with semver tags (v1.2.3), and a floating major tag
(v2) follows the latest release of each major. The major version changes
only on breaking changes to the action inputs or to the payload, see
Protocol versioning.
How to reference it, from most to least locked down:
-
@<commit sha> # v1.2.3: immutable. Recommended, because the action is handed yourMUELLE_SECRET. Let Dependabot bump the SHA and the comment together:# .github/dependabot.yml version: 2 updates: - package-ecosystem: github-actions directory: / schedule: interval: weeklyResolve a tag to its commit with
git ls-remote https://github.com/haztecaso/muelle 'refs/tags/v1.2.3^{}'(the^{}matters: an annotated tag’s own SHA does not work). -
@v1.2.3: readable, but tags can be moved. -
@v1: follows every compatible release automatically. Fine for repos you own when you trust the muelle repo as much as the host.
Never use @main outside of testing muelle itself.
Pin the flake input on the host the same way (github:haztecaso/muelle/v1.2.3
or a locked flake.lock), and update host and action together across
majors; see Upgrade notes.
Upgrade notes
Changes to the host configuration needed when updating the flake input. Releases not listed need none.
v3.1.0 to v3.2.0
- Every vhost now also sends
Referrer-Policy: strict-origin-when-cross-origin,X-Frame-Options: DENYandContent-Security-Policy: frame-ancestors 'none'. A site embedded in another site’s iframe stops loading there: drop or relax them withsites.<name>.headers(see Security model). A site that sends its ownContent-Security-PolicythroughextraConfignow sends two: move it tosites.<name>.headers. securityHeaders(global and per site) is deprecated in favour ofheadersand warns. While set, it replacesheadersas before.sites.<name>.immutablePathsis new (see Caching hashed assets).
v3.0.0 to v3.1.0
- Nothing required.
sites.<name>.publicPreviewVhostis new: settings added straight toservices.nginx.virtualHosts.muelle-apex-<site>for public previews can move there.
v2.2.0 to v3.0.0
sites.<name>.redirectFromis replaced bysites.<name>.previewApex, a single apex, with no alias: evaluation fails until it is renamed.redirectFrom = [ "example.com" ]becomespreviewApex = "example.com". Its vhost is now namedmuelle-apex-<site>.sites.<name>.publicPreviewsserves next and previews onpreviewApexwithout the gate (see Gating previews).
v2.0.0 to v2.2.0
services.muelle.previewVhostDefaultsis renamed toservices.muelle.previewVhost(#31), with no alias: evaluation fails until it is renamed.prodBranchesdefaults to[ "main" ](#28). Sites that deploy prod from another branch must list it, and sites that deploy prod from tags needprodBranches = null, since tag names are rejected (#36).- The action gained
action: announceandaction: abort(v2.2.0); they are optional, see Following deploys in the listing. An older host answers them withinvalid action, which the action only warns about.
Architecture
sequenceDiagram
participant CI as GitHub Actions
participant W as webhook (host)
participant R as muelle-receive
participant K as muelle-worker
CI->>CI: build, upload-artifact
CI->>W: POST /hooks/#lt;site#gt; (HMAC-signed)
W->>W: check HMAC
W->>R: payload
R->>R: validate against the Nix site table, spool
R-->>K: detach worker
R-->>CI: {id, url} (through webhook)
K->>K: download artifact (GITHUB_TOKEN), check sha256
K->>K: extract, flip current, prune
loop until success or failure
CI->>W: GET /status/#lt;id#gt;
W-->>CI: status file
end
CI->>CI: set GitHub Deployment state
Pull, not push
CI never gets shell access to the host and never applies NixOS configuration. It can only ask the host to fetch a build of a site the NixOS module declares, into an environment the module allows. The module is the only authority on which sites, environments and paths exist; the payload only picks among them.
Pieces
- Receiver: adnanh/webhook via
services.webhook, one hook per site,payload-hmac-sha256rule, secret loaded with systemdLoadCredential. Once the signature checks out it runsmuelle-receive(muelle.receive), which validates the payload against the site table generated by the module, writes it to the spool, detaches the worker and answers with the job’s id and URL. - Worker (
muelle.worker): downloads the artifact, checks its sha256, extracts it safely into a new release, flips the slot’scurrentsymlink, prunes old releases and previews, and keeps the status file updated. - Client (
muelle.client): run by the composite action; signs the payload, polls/status/#lt;id#gt;until the job ends, and reports GitHub Deployment state. - Listing (
muelle.index): staticindex.htmlandindex.json, regenerated on every hook request and daily. - Admin CLI (
muelle.cli): the same operations from the host, without CI.
All of it is one Python package without runtime dependencies. The client
imports only muelle.protocol and the
standard library, so the action runs it straight from the checkout.
Credentials
The host holds no GitHub credentials. The workflow’s short-lived
GITHUB_TOKEN is passed in the signed payload and used only to download the
artifact, which must live under https://api.github.com/repos/<repo>/ of the
site’s repo. The token stays valid while the action waits for the host.
Layout
<baseDir>/<site>/<slot>/releases/<sha> plus a current symlink. Slots are
prod, next, and an 8-hex hash of site + branch + sha per preview. Static
content needs no nginx reload: the symlink flip is atomic. See
Operating the host.
Security model
Requests
- HMAC-SHA256 over the raw body, per-site secret. A secret only works on its own site’s hook.
- The payload is then validated against the Nix-declared site table: site
name must match the hook, env must be allowed, prod only from
prodBranches, artifact URL (andrun_url) must belong to the site’s repo, fields match strict regexes. - Replay:
tsmust be withinmaxSkewseconds, and eachidis accepted once. /hooks/is rate limited in nginx (hookRateLimit).endpointmust behttps://in the client: the body carries the job’s token.
prodBranches is a guard against mistakes, not against a leaked secret: the
branch is part of what the secret signs. See
Branch policy.
Artifacts
Archives (zip or tar.gz) with absolute paths, .. components, symlinks or
any non-regular file are rejected, as are archives whose total uncompressed
size exceeds maxExtractedBytes (2 GiB) or that hold more than
maxArtifactFiles (50 000) entries, checked before anything is written.
Downloads are bounded in size and never follow a redirect from https to
http.
The host
- The receiver and worker run as the unprivileged
muelleuser under systemdProtectSystem=strict, writable paths limited tobaseDirandstateDir. /status/<id>is public (CI polls it), so unexpected errors show onlyinternal error; the detail and traceback stay in<stateDir>/log/<id>.log. It carries state, message and URL only, never branch names, which stay in the unserved<stateDir>/jobs/.
Headers
Every vhost muelle declares sends headers, one definition per header so
each can be changed or dropped (null) on its own, globally or per site:
Strict-Transport-Security: max-age=31536000, withoutincludeSubDomainsorpreload, since the apex may not be yoursX-Content-Type-Options: nosniffReferrer-Policy: strict-origin-when-cross-originX-Frame-Options: DENYandContent-Security-Policy: frame-ancestors 'none': other sites cannot frame yours (clickjacking)
A site meant to be embedded drops or relaxes the last two:
services.muelle.sites.mysite.headers = {
X-Frame-Options = null;
Content-Security-Policy = "frame-ancestors https://partner.example";
};
Set headers there, not through extraConfig, which would send them twice.
A full Content-Security-Policy for a site replaces the default one, so
include frame-ancestors in it. nginx drops server-level add_headers in
any location that sets its own, so repeat them there.
The listing and /status/ send their own strict Content-Security-Policy
and Referrer-Policy: no-referrer instead.
Previews
next and previews serve untrusted content same-site with the listing; see Preview isolation.
Protocol versioning
The payload carries protocol (currently 1) and the host rejects
protocols it does not speak, so a host and an action of different majors
fail loudly instead of half-working.
The action’s major version changes only on breaking changes to the action
inputs or to the payload, together with protocol. Additive changes keep
both: a new optional field (like run_url) is ignored by hosts that predate
it, and a new action (like announce) is answered with invalid action by
them, which the client handles.
Pushing a vX.Y.Z tag runs release.yml, which creates the GitHub release
and moves the floating major tag (vX) to it. See
Versioning and pinning the action for how to
reference a release.
NixOS options
Generated from the module in nix/modules.
Every option is under services.muelle; site options under services.muelle.sites.<name>.
services.muelle.enable
Whether to enable muelle deploy receiver.
Type: boolean
Default:
false
Example:
true
Declared by:
services.muelle.accessLogFormat
nginx log_format name for prod vhost access logs (must be defined elsewhere). Null uses nginx’s default.
Type: null or string
Default:
null
Example:
"withHost"
Declared by:
services.muelle.acmeHost
ACME cert (security.acme.certs name) covering domain and *.<domain>.
Type: string
Declared by:
services.muelle.artifactUrlBase
Artifacts must be fetched from <artifactUrlBase>/<repo>/.
Type: string
Default:
"https://api.github.com/repos"
Declared by:
services.muelle.baseDir
Root of <site>/<slot>/{releases,current}.
Type: string
Default:
"/var/www/muelle"
Declared by:
services.muelle.domain
Host serving /hooks/<site>, /status/<id> and the listing of
next/preview environments at /. Those environments are served at
next-<site>.<domain> and <hash>-<site>.<domain>.
Type: string
Example:
"muelle.example.com"
Declared by:
services.muelle.headers
Response headers sent by every vhost muelle declares, as
name = value; null drops one. Defaults, each overridable on its
own:
Content-Security-Policy: frame-ancestors 'none'Referrer-Policy: strict-origin-when-cross-originStrict-Transport-Security: max-age=31536000X-Content-Type-Options: nosniffX-Frame-Options: DENY
HSTS leaves out includeSubDomains and preload: the apex may not be
yours. Per site: sites.<name>.headers. The listing and /status/
always send their own strict Content-Security-Policy and
Referrer-Policy. nginx drops server-level add_header directives in
a location that sets its own: repeat them there.
Type: attribute set of (null or string)
Default:
{ }
Example:
{
Content-Security-Policy = "frame-ancestors https://partner.example";
X-Frame-Options = null;
}
Declared by:
services.muelle.hookRateLimit
nginx limit_req rate for /hooks/, per client IP (burst 5).
Type: string
Default:
"20r/m"
Declared by:
services.muelle.indexVhost
A services.nginx.virtualHosts.<name> module merged into the domain
vhost, after previewVhost. Its / lists the next/preview
deployments: gate it, it reveals branch names and URLs. Gate
location / only (as enableAuth-style modules do): /hooks/ and
/status/ are separate locations and must stay reachable from CI.
Type: module
Default:
{ }
Example:
{ locations."/".extraConfig = "auth_request /auth;"; }
Declared by:
services.muelle.keepPreviews
Preview slots kept per site (oldest removed first).
Type: positive integer, meaning >0
Default:
10
Declared by:
services.muelle.keepReleases
Releases kept per slot.
Type: positive integer, meaning >0
Default:
3
Declared by:
services.muelle.maxArtifactBytes
Maximum artifact download size.
Type: positive integer, meaning >0
Default:
209715200
Declared by:
services.muelle.maxArtifactFiles
Maximum number of entries (files and directories) in an artifact.
Type: positive integer, meaning >0
Default:
50000
Declared by:
services.muelle.maxExtractedBytes
Maximum total uncompressed size of an artifact (guards against zip bombs).
Type: positive integer, meaning >0
Default:
2147483648
Declared by:
services.muelle.maxSkew
Seconds a request timestamp may differ from the server clock.
Type: signed integer
Default:
300
Declared by:
services.muelle.port
Local port of the webhook daemon.
Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)
Default:
9077
Declared by:
services.muelle.previewTtlDays
Days after its last deploy a preview is removed (daily, by muelle-prune.timer).
Null disables expiry. Overridable per site.
Type: null or (positive integer, meaning >0)
Default:
30
Declared by:
services.muelle.previewVhost
A services.nginx.virtualHosts.<name> module merged into every
next/preview vhost and into the domain vhost (the listing), e.g.
an auth gate. Definitions merge like any vhost definition: per-site
previewVhost and indexVhost add to it, and override its values
with lib.mkForce.
Type: module
Default:
{ }
Example:
{
enableAuth = true;
}
Declared by:
services.muelle.securityHeaders
Deprecated, use headers. When set, these nginx add_header
directives replace headers on every vhost, as before 3.2.0; ""
sends none.
Type: null or strings concatenated with “\n”
Default:
null
Declared by:
services.muelle.sites
Sites that can be deployed.
Type: attribute set of (submodule)
Default:
{ }
Declared by:
services.muelle.sites.<name>.acmeHost
ACME cert (security.acme.certs name) of the prod vhost.
Type: null or string
Default:
domain
Declared by:
services.muelle.sites.<name>.domain
Domain of the prod environment. When set, muelle declares its nginx vhost:
HTTPS only, rooted at root, try_files like next/preview, logs in
/var/log/nginx/<site>-{error,access}.log. Extend it through
services.nginx.virtualHosts.<domain> (e.g. extra locations).
Type: null or string
Default:
null
Example:
"example.com"
Declared by:
services.muelle.sites.<name>.envs
Environments this site may deploy to. [ "prod" ] disables next and previews.
Type: list of (one of “prod”, “next”, “preview”)
Default:
[
"prod"
"next"
"preview"
]
Declared by:
services.muelle.sites.<name>.extraConfig
Extra nginx config for the prod vhost’s server block.
Type: strings concatenated with “\n”
Default:
""
Declared by:
services.muelle.sites.<name>.headers
Response headers of this site’s prod, next/preview and apex vhosts,
merged header by header over services.muelle.headers; null drops one.
Type: attribute set of (null or string)
Default:
{ }
Example:
{
Content-Security-Policy = "frame-ancestors https://partner.example";
X-Frame-Options = null;
}
Declared by:
services.muelle.sites.<name>.immutablePaths
URL path prefixes whose files never change, because their names
carry a content hash (e.g. Astro’s /_astro/, Vite’s /assets/).
They are sent with Cache-Control: public, max-age=31536000, immutable on prod, next and previews, so browsers keep them a
year without revalidating. Never list paths whose files change in
place: browsers would keep stale copies.
Type: list of string matching the pattern /.*
Default:
[ ]
Example:
[
"/_astro/"
]
Declared by:
services.muelle.sites.<name>.previewApex
Apex domain whose next.<apex> and <hash>.<apex> subdomains expose this
site’s next/preview slots: a 302 to <slot>-<site>.<domain>, or the slot
itself with publicPreviews. Needs an ACME cert of the same name covering *.<apex>.
Type: null or string
Default:
null
Example:
"example.com"
Declared by:
services.muelle.sites.<name>.previewTtlDays
Days after its last deploy a preview of this site is removed. Null keeps previews until pruned by count.
Type: null or (positive integer, meaning >0)
Default:
config.services.muelle.previewTtlDays
Declared by:
services.muelle.sites.<name>.previewVhost
A services.nginx.virtualHosts.<name> module merged into this
site’s next/preview vhost, after services.muelle.previewVhost.
Type: module
Default:
{ }
Example:
{ basicAuthFile = "/run/secrets/htpasswd"; }
Declared by:
services.muelle.sites.<name>.prodBranches
Branches allowed to deploy to prod; requests for prod from any other branch are rejected. Null allows every branch. The branch comes from the signed payload, so this guards against mistakes (a feature branch deploying to prod), not against a leaked secret.
Type: null or (list of string)
Default:
[
"main"
]
Example:
[
"main"
"release"
]
Declared by:
services.muelle.sites.<name>.prodUrl
Public URL of the prod environment, reported back to CI.
Type: string
Default:
"https://${domain}" if domain is set
Example:
"https://example.com"
Declared by:
services.muelle.sites.<name>.publicPreviewVhost
A services.nginx.virtualHosts.<name> module merged into this
site’s public next/preview vhost on previewApex (only with
publicPreviews). Neither previewVhost is merged there, so
this is the place for the site’s own settings, such as error pages.
Type: module
Default:
{ }
Example:
{ extraConfig = "error_page 404 /404.html;"; }
Declared by:
services.muelle.sites.<name>.publicPreviews
Serve next/previews on previewApex without previewVhost (no gate) and
report their URLs there. Their content then shares a site with prod: see
Gating previews. <slot>-<site>.<domain> stays as it is.
Type: boolean
Default:
false
Declared by:
services.muelle.sites.<name>.repo
GitHub repository (owner/name) allowed to deploy this site. Artifacts are only fetched from its API.
Type: string matching the pattern [A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+
Example:
"octocat/example.com"
Declared by:
services.muelle.sites.<name>.root
Document root of the prod environment (a symlink flipped on deploy). Use it in your own vhost if domain is unset.
Type: string (read only)
Default:
"${baseDir}/<name>/prod/current"
Declared by:
services.muelle.sites.<name>.secretFile
File holding the HMAC secret for this site (e.g. an agenix secret path).
Read by systemd through LoadCredential, so it can stay root-only.
Use a hex string (openssl rand -hex 32).
Type: absolute path
Declared by:
services.muelle.sites.<name>.securityHeaders
Deprecated, use headers. When set, these nginx add_header
directives replace this site’s headers, as before 3.2.0.
Type: null or strings concatenated with “\n”
Default:
null
Declared by:
services.muelle.stateDir
Status and job files, spool, logs and locks.
Type: string
Default:
"/var/lib/muelle"
Declared by:
Action inputs and outputs
Generated from action.yml. See Your first workflow for a complete workflow and Payload and status API for what the action sends.
Ask a muelle host to deploy (or tear down) a static site built in this workflow.
Inputs
| input | required | default | description |
|---|---|---|---|
endpoint | yes | Base URL of the muelle receiver, e.g. https://muelle.example.com | |
site | yes | Site name as declared in services.muelle.sites | |
secret | yes | HMAC secret shared with the host for this site | |
action | deploy | deploy | teardown | announce | abort | |
environment | preview | prod | next | preview | |
artifact-id | artifact-id output of actions/upload-artifact (deploy) | ||
artifact-digest | artifact-digest output of actions/upload-artifact (deploy) | ||
branch | Branch name; defaults to the triggering branch (the deleted one for delete events) | ||
timeout-seconds | 600 | How long to wait for the host to finish | |
github-token | ${{ github.token }} | Token used to download the artifact and to report GitHub Deployments | |
deployments | true | Report GitHub Deployment state (true | false) |
Outputs
| output | description |
|---|---|
url | URL of the deployed environment |
Environment of the client
The action runs muelle.client, mapping each input to a MUELLE_* variable. The same client runs outside GitHub Actions as muelle-client:
| variable | value |
|---|---|
MUELLE_ENDPOINT | ${{ inputs.endpoint }} |
MUELLE_SITE | ${{ inputs.site }} |
MUELLE_SECRET | ${{ inputs.secret }} |
MUELLE_ACTION | ${{ inputs.action }} |
MUELLE_ENV | ${{ inputs.environment }} |
MUELLE_ARTIFACT_ID | ${{ inputs.artifact-id }} |
MUELLE_SHA256 | ${{ inputs.artifact-digest }} |
MUELLE_BRANCH | ${{ inputs.branch || (github.event_name == 'delete' && github.event.ref) || '' }} |
MUELLE_SHA | ${{ github.event.pull_request.head.sha || github.sha }} |
MUELLE_TIMEOUT | ${{ inputs.timeout-seconds }} |
MUELLE_TOKEN | ${{ inputs.github-token }} |
MUELLE_DEPLOYMENTS | ${{ inputs.deployments }} |
GH_TOKEN | ${{ inputs.github-token }} |
PYTHON | ${{ steps.python.outputs.python-path }} |
Admin CLI
Generated from the argparse parser in src/muelle/cli.py. See Operating the host for how to use it.
usage: muelle [-h] {status,releases,prune,teardown,rm,index,jobs,log} ...
muelle admin CLI
positional arguments:
{status,releases,prune,teardown,rm,index,jobs,log}
status slots, current release and URL of each site
releases kept releases of a slot (* = current)
prune apply previewTtlDays, keepPreviews and keepReleases
now
teardown remove every preview of a branch
rm remove one next or preview slot
index rebuild the listing
jobs recent jobs, newest first
log log of a job
options:
-h, --help show this help message and exit
muelle status
slots, current release and URL of each site.
usage: muelle status [-h] [site]
positional arguments:
site
options:
-h, --help show this help message and exit
muelle releases
kept releases of a slot (* = current).
usage: muelle releases [-h] site slot
positional arguments:
site
slot prod, next or a preview hash
options:
-h, --help show this help message and exit
muelle prune
apply previewTtlDays, keepPreviews and keepReleases now.
usage: muelle prune [-h] [--no-record] [site]
positional arguments:
site
options:
-h, --help show this help message and exit
--no-record no host job (used by muelle-prune.timer)
muelle teardown
remove every preview of a branch.
usage: muelle teardown [-h] site branch
positional arguments:
site
branch
options:
-h, --help show this help message and exit
muelle rm
remove one next or preview slot.
usage: muelle rm [-h] site slot
positional arguments:
site
slot
options:
-h, --help show this help message and exit
muelle index
rebuild the listing.
usage: muelle index [-h]
options:
-h, --help show this help message and exit
muelle jobs
recent jobs, newest first.
usage: muelle jobs [-h] [-n N] [site]
positional arguments:
site
options:
-h, --help show this help message and exit
-n N how many (default 20)
muelle log
log of a job.
usage: muelle log [-h] id
positional arguments:
id
options:
-h, --help show this help message and exit
Payload and status API
The client (muelle.client) builds and signs the
payload, and the receiver (muelle.receive) validates
it; both share muelle.protocol. Action inputs map to
these fields as listed in Action inputs and outputs.
Request
POST /hooks/<site> on domain, with header
X-Muelle-Signature: sha256=<hex hmac of the raw body> (HMAC-SHA256 with
the site’s secret).
deploy
{
"protocol": 1,
"id": "1234-1-mysite-1730000000",
"site": "mysite",
"action": "deploy",
"env": "preview",
"branch": "feat/x",
"sha": "<40 hex>",
"sha256": "<64 hex, of the artifact file>",
"artifact_url": "https://api.github.com/repos/octocat/mysite/actions/artifacts/<id>/zip",
"token": "<GITHUB_TOKEN>",
"run_url": "https://github.com/octocat/mysite/actions/runs/<id>",
"ts": 1730000000
}
teardown
action: "teardown", env: "preview" and branch, without sha256,
artifact_url and token. Removes every preview slot deployed from that
branch.
announce and abort
action: "announce" or "abort" with env, branch, sha and
run_url, without sha256, artifact_url and token. They only update
the listing; see Following deploys in the listing.
Fields
protocol: see Protocol versioning. A payload without it is protocol 1.id: unique per request; each id is accepted once.ts: Unix time; must be withinmaxSkewseconds of the host’s clock.artifact_url: must be underhttps://api.github.com/repos/<the site's repo>/.run_url: optional in every payload; when present it must behttps://github.com/<the site's repo>/actions/runs/<digits>. The client sends it only on github.com (GHES runs send none). Hosts that predate it ignore it.
Responses
200with{id, state, url, status_url}when a deploy or teardown is queued (stateisqueued).200with{id, state, url}for announce and abort,statebeingqueued(announce listed),failure(abort listed) orignored(abort of a run that is not the newest job any more).500with the reason when the signature or the payload is rejected (webhook reports HMAC mismatches as 500 too).
Status
GET /status/<id> returns the job’s
status file:
{"id": "...", "state": "queued|in_progress|success|failure", "message": "...", "url": "...", "updated": "2026-01-01T00:00:00Z"}
The client polls it until state is success or failure.
Files on the host
Where they live is described in
Operating the host. Times are UTC,
YYYY-MM-DDTHH:MM:SSZ.
Status file
<stateDir>/status/<id>.json, served publicly as /status/<id>:
| field | content |
|---|---|
id | job id |
state | queued, in_progress, success or failure |
message | human-readable progress or error (internal error for unexpected ones) |
url | URL of the environment |
updated | time of the last change |
Job file
<stateDir>/jobs/<id>.json, not served. Host jobs carry only the fields that apply to them:
| field | content |
|---|---|
id | job id (host-... for jobs started by the admin CLI) |
site | site name (comma-separated for a CLI prune of several sites) |
action | deploy, teardown, announce, abort, or the CLI’s prune, teardown, rm |
env | prod, next or preview |
branch | branch of the request |
sha | commit |
slot | slot removed by muelle rm |
run_url | GitHub Actions run, if the request carried one |
url | URL of the environment |
created | time the job was recorded |
meta.json
<baseDir>/<site>/<slot>/meta.json, the last deploy of a slot:
| field | content |
|---|---|
site, env, branch, sha | from the deploy request |
run_url | run that deployed it (empty if none) |
deployed_at | time of the deploy |
index.json
<stateDir>/index/index.json, served as /index.json next to the listing:
generated: time it was written.entries: deployed next and preview environments, each withsite, env, branch, sha, deployed_at, slot, url, repo, prod, run_url.jobs: jobs shown in the listing (see Which job is shown), each withid, site, action, env, branch, sha, url, run_url, state, message, updated, repo, prod.
repo is the site’s GitHub repository and prod its prod URL.
muelle.archive
Source: src/muelle/archive.py.
Safe extraction of site artifacts (zip or tar, optionally compressed).
ArchiveError
class ArchiveError(Exception)
check_name
def check_name(name: str) -> None
Rejects member names that could escape the destination.
extract
def extract(
archive: Path,
dest: Path,
*,
max_bytes: int = DEFAULT_MAX_BYTES,
max_files: int = DEFAULT_MAX_FILES,
) -> None
Extracts ARCHIVE into DEST (created), rejecting anything but plain files and dirs.
MAX_BYTES bounds the total uncompressed size, MAX_FILES the number of entries.
muelle.cli
Source: src/muelle/cli.py.
muelle: admin CLI on the host.
Operations that should not depend on CI being available. Reads the same
MUELLE_CONFIG and takes the same locks as the worker; the NixOS module's
`muelle` wrapper sets MUELLE_CONFIG and runs it as the muelle user.
Commands that change slots (prune, teardown, rm) are recorded like hook
requests: a `host-...` status file and log, then the listing is refreshed.
CliError
class CliError(Exception)
status
def status(config: Config, sites: list[str], out: IO[str]) -> None
releases
def releases(config: Config, site: str, slot: str, out: IO[str]) -> None
jobs
def jobs(config: Config, limit: int, site: str | None, out: IO[str]) -> None
show_log
def show_log(config: Config, id: str, out: IO[str]) -> None
host_job
def host_job(config: Config, description: str, out: IO[str], **job: str) -> Generator[str]
Records a host action like a hook request: job and status files, log, then the listing.
teardown
def teardown(config: Config, site: str, branch: str, out: IO[str]) -> None
rm
def rm(config: Config, site: str, slot: str, out: IO[str]) -> None
prune
def prune(config: Config, sites: list[str], out: IO[str]) -> None
run
def run(argv: Sequence[str], config: Config, out: IO[str] = sys.stdout) -> int
main
def main() -> int
muelle.client
Source: src/muelle/client.py.
muelle-client: asks a muelle host to deploy or tear down a site and waits for
the result. Used by the composite action (action.yml); configured through
MUELLE_* environment variables so it can also run outside GitHub Actions.
Required: MUELLE_ENDPOINT, MUELLE_SITE, MUELLE_SECRET
Deploy: MUELLE_SHA256 and either MUELLE_ARTIFACT_URL or MUELLE_ARTIFACT_ID
(resolved against the GitHub API of the current repository)
Optional: MUELLE_ACTION (deploy | teardown | announce | abort), MUELLE_ENV (preview), MUELLE_BRANCH, MUELLE_SHA,
MUELLE_TOKEN (sent for the artifact download), MUELLE_TIMEOUT (600),
MUELLE_POLL_INTERVAL (3), MUELLE_DEPLOYMENTS (true: report GitHub
Deployment state, authenticated with GH_TOKEN or MUELLE_TOKEN),
MUELLE_ALLOW_INSECURE (false: allow http:// to non-loopback hosts)
The endpoint must be https://, except for loopback hosts: the body carries
the GITHUB_TOKEN used for the artifact download, and the HMAC signature
authenticates it without hiding it.
announce (a build started) and abort (it failed or was cancelled) only update
the host's listing: they do not wait, and a failure is a warning, never an
error, so they cannot break a build.
TLS uses the system trust store; point SSL_CERT_FILE at a CA bundle to trust
a private CA.
Stdlib only: action.yml runs it on a python set up by actions/setup-python.
ClientError
class ClientError(Exception)
GitHub
class GitHub
Context of the GitHub Actions run, empty outside of it.
GitHub.run_url
def run_url(self) -> str
GitHub.listed_run_url
def listed_run_url(self) -> str
run_url as sent to the host, which only links to github.com.
Settings
class Settings
check_endpoint
def check_endpoint(endpoint: str, allow_insecure: bool = False) -> None
Refuses endpoints that would send the token in cleartext.
settings_from_env
def settings_from_env(env: Mapping[str, str]) -> Settings
Reads and checks the MUELLE_* / GITHUB_* variables.
request_id
def request_id(s: Settings, now: int, nonce: str | None = None) -> str
Unique per request: the host accepts each id once.
build_payload
def build_payload(s: Settings, id: str, now: int) -> dict[str, Any]
github_environment
def github_environment(env: str, branch: str) -> dict[str, Any]
GitHub Deployment fields for a muelle environment.
Deployment
class Deployment
GitHub Deployment reporting; every call is best effort.
Deployment.create
def create(self, sha: str, env: str, branch: str) -> None
Deployment.set_state
def set_state(self, state: str, url: str = "") -> None
wait_for_result
def wait_for_result(
endpoint: str,
id: str,
timeout: float,
interval: float,
http: Http = _http,
clock: Callable[[], float] = time.monotonic,
sleep: Callable[[float], None] = time.sleep,
) -> tuple[str, dict[str, Any]]
Polls the status file until success/failure; returns (state, status).
run
def run(s: Settings, http: Http = _http, now: Callable[[], float] = time.time, **wait_kw: Any) -> int
main
def main() -> int
muelle.config
Source: src/muelle/config.py.
Host configuration generated by the NixOS module (MUELLE_CONFIG).
Site
class Site
Config
class Config
Config.from_json
def from_json(cls, data: dict[str, Any]) -> Config
Config.load
def load(cls) -> Config
Config.state
def state(self) -> StateDir
Config.url_for
def url_for(self, site: str, slot: str) -> str
Config.slot_url
def slot_url(self, site: str, env: str, branch: str, sha: str) -> str
Config.status_url
def status_url(self, id: str) -> str
muelle.download
Source: src/muelle/download.py.
Artifact download: bounded size, retried, no downgrade from https.
DownloadError
class DownloadError(Exception)
download
def download(url: str, dest: Path, *, token: str, max_bytes: int, retries: int = 2, timeout: float = 60) -> None
sha256_file
def sha256_file(path: Path) -> str
muelle.index
Source: src/muelle/index.py.
Listing (`muelle index`)
Regenerates the listing of deployed next/preview environments served at the
muelle domain: <stateDir>/index/{index.json,index.html}. Above them, per site,
the jobs of every env still building or deploying, and recent failures.
Entry
class Entry(TypedDict)
Job
class Job(TypedDict)
job_key
def job_key(job: dict[str, Any]) -> tuple[str, str, str]
What a job is about: a newer job with the same key supersedes it. Previews are
per branch (a new commit supersedes the last); prod and next are one slot each.
latest_jobs
def latest_jobs(jobs: Iterable[dict[str, Any]]) -> dict[tuple[str, str, str], dict[str, Any]]
The newest job of each key. Times have one-second resolution: on a tie, an
announce is older than the abort that fails it, and both are older than a deploy.
is_pending
def is_pending(job: Job) -> bool
collect_jobs
def collect_jobs(config: Config, now: datetime) -> list[Job]
Per key, the newest job if it is still pending or failed recently: grouped by site, newest first.
read_meta
def read_meta(slot_dir: Path) -> dict[str, Any]
collect
def collect(config: Config) -> list[Entry]
Deployed next/preview slots: grouped by site, next first, then newest first.
Markup
class Markup(str)
HTML that html() inserts verbatim.
html
def html(template: Template) -> Markup
Renders a t-string, escaping every interpolated value that is not Markup.
render
def render(entries: list[Entry], generated: str, jobs: list[Job] | None = None) -> str
write
def write(config: Config) -> None
muelle.protocol
Source: src/muelle/protocol.py.
Wire format shared by the client (CI runner) and the receiver (host).
The client imports this module too, so it must stay stdlib-only.
encode
def encode(payload: dict[str, Any]) -> bytes
Serializes a payload exactly as it is signed and sent.
sign
def sign(body: bytes, secret: str) -> str
Returns the X-Muelle-Signature header value for BODY.
slot_for
def slot_for(site: str, env: str, branch: str, sha: str) -> str
Directory name of an environment: prod, next, or 8 hex chars per preview commit.
is_preview_slot
def is_preview_slot(name: str) -> bool
deploy_payload
def deploy_payload(
*,
id: str,
site: str,
env: str,
branch: str,
sha: str,
sha256: str,
artifact_url: str,
token: str,
ts: int,
run_url: str = "",
) -> dict[str, Any]
teardown_payload
def teardown_payload(*, id: str, site: str, branch: str, ts: int) -> dict[str, Any]
notice_payload
def notice_payload(
*, id: str, site: str, action: Literal["announce", "abort"], env: str, branch: str, sha: str, run_url: str, ts: int
) -> dict[str, Any]
Announce (a build started in CI) and abort (it failed or was cancelled before deploying).
muelle.prune
Source: src/muelle/prune.py.
Pruning (`muelle prune`)
Removes preview slots whose last deploy is older than the site's preview TTL,
then applies keepPreviews and keepReleases (never the release `current`
points to), and refreshes the listing. Run daily by muelle-prune.timer.
deployed_at
def deployed_at(slot: Path) -> datetime
Time of the slot's last deploy; the dir's mtime if meta.json is missing or bad.
expired
def expired(config: Config, site: str, now: datetime) -> list[Path]
prune
def prune(config: Config, now: datetime | None = None, sites: list[str] | None = None) -> int
Prunes SITES (default: all); returns how many expired previews were removed.
muelle.receive
Source: src/muelle/receive.py.
muelle-receive SITE
Run by webhook after the HMAC rule has passed, with the request body in
$MUELLE_PAYLOAD. Validates it against the Nix-declared site table, queues it in
the spool dir and detaches the worker. Announce and abort only update the
listing: no spool, no worker. Stdout is the HTTP response body; a
non-zero exit makes webhook answer 500 with the stderr message.
Rejected
class Rejected(Exception)
field
def field(payload: dict[str, Any], key: str) -> str
Reads KEY as a string; missing, null and false read as empty.
validate
def validate(payload: object, hook_site: str, config: Config, now: int) -> str
Checks a payload against the site table; returns the URL it deploys to ("" for a
teardown) or raises Rejected with a reason.
spool
def spool(state: StateDir, id: str, raw: str) -> None
Queues RAW for the worker. Creating the spool file is the replay gate: an id is accepted once.
notice
def notice(config: Config, id: str, job: dict[str, str], url: str) -> dict[str, str]
Records an announce (building in CI) or an abort (that build failed or was
cancelled), then refreshes the listing. An abort only fails the announce of the same
run that is still the newest job for its env/branch: a deploy that got further
already has its own state.
detach_worker
def detach_worker(config: Config, id: str) -> None
Runs the worker in a forked session that outlives this process.
The child must not keep webhook's stdout/stderr pipes open, or webhook
would wait for the deploy to finish before answering.
handle
def handle(
raw: str,
hook_site: str,
config: Config,
now: int,
spawn: Callable[[Config, str], None] = detach_worker,
) -> dict[str, str]
main
def main(argv: list[str] | None = None) -> int
muelle.state
Source: src/muelle/state.py.
Files under stateDir: status, jobs, spool, logs and locks.
utc_now
def utc_now() -> str
write_atomic
def write_atomic(dest: Path, content: str, mode: int = 0o644) -> None
Replaces DEST so readers (nginx) never see a partial file.
write_json_atomic
def write_json_atomic(dest: Path, data: Any) -> None
StateDir
class StateDir
StateDir.status_path
def status_path(self, id: str) -> Path
StateDir.spool_path
def spool_path(self, id: str) -> Path
StateDir.log_path
def log_path(self, id: str) -> Path
StateDir.job_path
def job_path(self, id: str) -> Path
StateDir.write_job
def write_job(self, id: str, **fields: str) -> None
Records what job ID is about (site, action, env, branch, ...). Kept apart from
the status file, which /status/ serves publicly: branch names stay off it.
StateDir.read_job
def read_job(self, id: str) -> dict[str, Any]
StateDir.jobs
def jobs(self) -> list[dict[str, Any]]
Every job that has a status file, its job file merged in; newest update first.
StateDir.write_status
def write_status(self, id: str, state: State, message: str, url: str = "") -> None
StateDir.lock
def lock(self, name: str) -> Generator[None]
Holds an exclusive flock on locks/NAME.lock, blocking until it is free.
muelle.worker
Source: src/muelle/worker.py.
Deploy worker.
Forked by muelle-receive (receive.detach_worker). Reads the already-validated payload from the
spool dir, deploys or tears down, and keeps the status file updated.
DeployError
class DeployError(Exception)
Terminated
class Terminated(BaseException)
Raised on SIGTERM (e.g. service restart) so the failure gets recorded.
Job
class Job
Job.from_payload
def from_payload(cls, id: str, payload: dict[str, Any]) -> Job
log
def log(message: str) -> None
subdirs
def subdirs(directory: Path) -> list[Path]
prune
def prune(dirs: list[Path], keep: int, key: Callable[[Path], float], protect: str = "") -> None
Removes DIRS beyond the newest KEEP (ranked by KEY), never PROTECT.
mtime
def mtime(path: Path) -> float
preview_slots
def preview_slots(site_dir: Path) -> list[Path]
deploy
def deploy(config: Config, job: Job, state: StateDir, fetch: Downloader = download) -> str
Installs the artifact as the slot's current release; returns the slot URL.
current_release
def current_release(slot_dir: Path) -> str
Name of the release `current` points to, "" if none.
teardown
def teardown(config: Config, site: str, branch: str) -> int
Removes every preview of BRANCH; returns how many.
refresh_index
def refresh_index(config: Config) -> None
Best effort: a listing that fails to render must not fail the job.
process
def process(config: Config, job: Job, fetch: Downloader = download) -> None
run
def run(config: Config, id: str, fetch: Downloader = download) -> int
Entry point of the detached worker process: a kill is recorded as a failure.
process_spooled
def process_spooled(config: Config, id: str, fetch: Downloader = download) -> int
Processes spooled job ID, recording any failure in its status file.
Development
Client, receiver, worker, index and admin CLI are one Python 3.14 package
without runtime dependencies (src/muelle), managed with uv:
nix develop # uv + python 3.14 (or any uv install)
uv run pytest # unit and property tests (tests/unit, tests/property)
uv run ruff check && uv run ruff format --check
uv run ty check
nix build .#muelle # package, runs the unit tests with nixpkgs' python
nix build .#docs # this site, into ./result
nix flake check # also module eval tests, config parity, docs, links and the NixOS VM test
The NixOS module is in nix/modules: core/ (site table, config JSON, admin
CLI, systemd units), nginx/ (the domain vhost and what every vhost
shares) and static/ (prod, preview and redirect vhosts of static sites).
Documentation
This site is mdBook, built by
nix/docs.nix. Hand-written pages are in docs/src; the reference is
generated at build time, so nothing in it is written twice:
- NixOS options:
pkgs.nixosOptionsDocover the module. - Action inputs and outputs:
action.yml. - Admin CLI: the argparse parser of
muelle.cli. - Python modules: the docstrings and signatures in
src/muelle, one page per module. A new module must be added todocs/src/SUMMARY.md, or the build fails.
The generators are in docs/gen/reference.py. nix flake check builds the
site and checks its internal links with lychee (offline: external links are
not checked). Pushes to main deploy it to GitHub Pages (pages.yml).
CI and releases
main is protected: changes land through pull requests once the two ci
jobs pass: lint (actionlint, SHA pins, nixfmt, flake evaluation, ruff, ty)
and check (pytest, a smoke test of the composite action, and
nix flake check with the package, module eval tests, docs and the NixOS VM
test on a KVM-enabled runner).
Every third-party action, including actions/setup-python inside the
composite action and the Pages actions, is pinned by commit SHA (lint
rejects tag references); Dependabot bumps the SHAs and their version
comments, and flake-update.yml opens a weekly flake.lock PR that merges
itself when ci passes.
To release, tag a commit on main with vX.Y.Z and push the tag:
release.yml creates the GitHub release and moves the floating major tag;
see Protocol versioning.