Skip to content

Deployment and updates

The fleet is deployed with colmena 🡕: a single command builds and applies the configuration on one or more hosts, remotely, from the admin workstation.

Fenêtre de terminal
just apply <target> [action] # alias : a
  • target = hostname, pattern ('*'), list (a,b) or colmena tag (@server).
  • action = switch (default), boot, test or build.
CommandPurpose
just apply <target>Build + activate on the target(s)
just apply-localApply on the current machine (alias al)
just apply-verbose <target>Same as apply in trace mode (alias av)

Build confidence through action: each step is less risky than the next.

Fenêtre de terminal
just apply <host> build # downloads + compiles: 100% safe, nothing is activated
just apply <host> test # activates without switching: no generation, no boot
just apply <host> # switch: activates and creates a new generation

Progress from core to edge: deploy nodes in this order, to never cut off access to a node by the one preceding it.

Diagram

The system is locked down by flakes. Updating = refreshing the inputs, then redeploying.

Fenêtre de terminal
just update-flake # met à jour dnf/ + racine, commit les locks
just apply '*' # déploie la mise à jour

fleet-update chains the entire update into a single command : flakes, building all hosts, publishing the locks across the fleet, testing in waves (hosts the network depends on first), then final activation of the approved hosts.

fleet-update interface

Fenêtre de terminal
just fleet-update [options]

The recipe picks the tool to run, in this order :

SituationTool run
Co-development (src/dnf-fleet-update/ present)The sources, with bun
Active darkone.admin.fleet-update moduleThe installed fleet-update command
Any other casenix run .#fleet-update, per the project’s flake.lock
  1. Update: nix flake update for the project, then for dnf/ (co-development), just clean, one commit per repository.
  2. Selection: hosts, profiles and zones read from var/generated/, filtered by --on; the current zone deduced from the local IP; one builder elected per host.
  3. Build: all selected hosts, reachable or not, each on its own builder. Presence probed through the deployment SSH connection, which also joins a roaming host.
  4. Publication: the closure of each reachable host is brought into its store, outside waves, before any activation.
  5. Test: switch-to-configuration test, one wave per profile; the next wave starts once all its hosts are OK or set aside.
  6. Switch: all hosts validated in test, in a single go, out of wave order.

Three options shorten this sequence :

OptionEffect
--build-onlyStops after the build; in interactive mode, offers to continue
--skip-testNo test: the switch happens wave by wave, right after the build
--skip-switchNo switch: the rollout stops at whatever the test left in place

The deployment machine must not be the fleet’s bottleneck. Each host is therefore built by the elected builder for it. The election is recalculated on every run from var/generated/, never declared : changing the deployment topology must not rebuild the fleet.

OrderSelected builderCondition
1The host itselfauto-build feature
2Its zone’s harmonia hostThe zone has one
3The global harmonia hostOne exists in the fleet
4The deployment machineDefault

A roaming host (roaming) is located at launch : the tool asks it which harmonia answers to the neutral name harmonia.dnf.internal.

  • Connected to a zone : that zone’s harmonia, declared or not.
  • Outside any zone : the deployment machine, or itself if it is also auto-build.
  • Unreachable : the deployment machine.

The rule comes down to one sentence : a builder must be able to serve what it builds. Hence the choice of harmonia hosts, whose /nix/store is already the cache for their zone, with nothing to bootstrap. A gateway without harmonia is not suitable : its paths are in no substituter.

etc/config.yaml
features: ["auto-build"]

The --no-distributed-build option brings everything back to the center, whatever the election. It is a debugging escape hatch : the rule comes from the fleet, the exception from the command line.

The fleet’s default values are declared in config.yaml :

etc/config.yaml
network:
fleetUpdate:
deploymentOrder: "hcs:gateway:server:[others]:laptop"
criticalProfiles: "hcs:gateway:server"
KeyRole
deploymentOrderOne test wave per host profile, in that order
criticalProfilesProfiles whose failures also go to the incident room

Profiles separated by :, [others] designates the unlisted profiles. Optional block : without it, the tool applies the values above. The --deployment-order and --critical-profiles options take precedence over config.yaml.

Two other optional blocks in config.yaml control the durations:

etc/config.yaml
network:
fleetUpdate:
pingInterval: 15
timeouts:
build: 10800
KeyRoleDefault
pingIntervalSeconds between two presence checks15
timeouts.<clé>Maximum duration of an operation, in secondsdepends on the operation

Keys in timeouts, in order of execution:

timeouts.<clé>Default (s)
flakeUpdate300
clean60
commit60
eval1200
build10800
publish3600
copy3600
activation300
ssh30
ping5
matrix30
killGrace10

A common error should be readable without knowing Nix. The tool keeps a signature table: a recognized pattern in a command’s output gives a plain-language message and the action to take.

Recognized patternWhat it meansAction
mismatch in field 'narHash'nix-eval-jobs isn’t bound to the same Nix as the systemStop
lacks a signature by a trusted keyThe deployment account isn’t a trusted user on this hostStop

The message is shown as the run progresses (hint:), once only, and is also found in the report’s Known errors section. It is added to the host’s reason, it never replaces it: the full trace stays in logs/.

Table actionWhat the tool does
RetryReplays the command, at most three times, if it is replayable: evaluation, build, derivation copy, pull
ExcludeContinues without the host; if already activated, first brings it back to its origin
StopStops the run, without asking any question

No signature calls for a retry today: the two known entries are stops.

Deterministic collection. A host that fails while remaining reachable is interrogated before any decision: systemctl status, list of failing units, then each one’s log since the start of its wave.

What is collectedWhere it goes
Full output of commands and logslogs/<hôte>.diag in the run folder
Failing units, error extractReport’s Diagnostics section, incident message

Unit restart. An activation that ends with failing units leaves the host in error state. The tool then attempts a simple repair.

  1. Ten-second wait: a unit that is slow to start isn’t a failing unit.
  2. systemctl restart of all the failing units, in a single command.
  3. Re-reading the failing-unit list: it is what concludes, not the exit code.

Everything comes back up → the host resumes its course, rejoins the switch with the others, and the report notes a probable activation-order issue (Notes section). A unit resists → the host stays in error, its name and the unit’s are in the report.

AI explains a failure: it reads the run state, logs, and if needed the code, then produces a plain-language analysis. With --ai-error-action repair it can then act: on failed units, or on the code (see Repairing a service). An analysis that fails, times out, or exceeds its budget leaves the host exactly where it was.

Two options control it, both set to none by default: nothing is sent to an AI until you ask for it. A third chooses the tool.

OptionDefaultRole
--ai-analysis none|passive|activenoneAnalysis depth, and end-of-run summary added to the report
--ai-error-action none|analysis|repairnoneWhat the AI does when a host fails
--ai-model <tool>[:<model>][@<effort>]claude:opus@highTool and model, for example opencode:ollama/qwen3:32b
--ai-context <text>noneInstruction or context added to all AI prompts
--ai-commit-messagedisabledSubjects of update commits written by the AI
Fenêtre de terminal
just fleet-update --ai-analysis passive # enriched report, nothing more
just fleet-update --ai-error-action analysis # each failure is explained

For example, --ai-context "Reply in French and stay concise." guides the style of responses. To avoid repeating it on every run, set it once for the host with the aiContext module option: it writes it to /etc/fleet-update/ai-context, which every run reads, both just fleet-update and the timer. The --ai-context option takes precedence over this file. On resume, the context from the initial run is reused; an explicit --ai-context replaces it.

# usr/machines/<host>/configuration.nix
darkone.admin.fleet-update.aiContext = "Reply in French and stay concise.";

--ai-commit-message makes the AI summarize each update commit: local commits since the previous run, changed flake inputs, and dnf/ commits brought into the project. No valid response → usual message.

The default model for the fleet is set in config.yaml; the option takes precedence:

etc/config.yaml
network:
fleetUpdate:
aiModel: "claude:opus@high"

AI tools are not a dependency of the tool. claude and opencode are looked for in PATH; the module’s aiPackages option adds them there for the daily run. If they are missing or refused → a warning during the run, a note in the report, and the rest proceeds without AI.

The AI has no free shell or SSH. It acts only through the tools of fleet-update, and the requested level fixes the list presented to it: what it does not see there, it cannot ask for.

LevelTools presented
passiveLaunch state, host diagnostic, build and activation logs, grouped launch warnings
active, analysis+ reading, searching and listing the code (project and dnf/), host units and logs (user units included), read-only
repair+ an action on a host’s failed units, and editing the code that describes them

The level used is the highest of the two options: --ai-analysis passive --ai-error-action analysis gives active. The built-in tools of claude and opencode are disabled, and the instructions these tools would pick up in the project (CLAUDE.md, user settings) are neutralized: the AI sees only what it is shown.

SafeguardEffect
Read pathConfined to the project and to dnf/, after resolving links; usr/secrets/ and .trash/ refused
Host, unitChecked against the launch table before any command
Excerpts200 log lines, 400 source lines, truncated at the end: the error is at the bottom
Timeout, budget300 seconds per analysis, two hours per repair session; 4 dollars per session for claude

Every tool call leaves a trace — a line in the launch stream (AI reads usr/modules/nginx.nix) and a line in logs/ai.log of the launch folder. A call refused by a safeguard is traced too, with its reason.

  1. A host fails, with --ai-error-action ≠ none: after the deterministic collection and the restart of units, before the question that decides its fate. The host shows AI analysis in magenta during this time, then returns to its state.
  2. A build fails, with --ai-error-action ≠ none: at the end of the build, one analysis per group of hosts broken by the same error, before the decision (see Repair a build).
  3. A host recovers after a unit restart, with --ai-analysis ≠ none: the analysis explains the activation order, without touching the host state.
  4. End of launch, with --ai-analysis ≠ none: a synthesis of the whole, written before the report that carries it.
  5. End of launch, with --ai-analysis active: a review of the warnings, which files improvement suggestions.
  6. Press a, at any time: a free question. It gets an answer even under --ai-analysis none — without any tool: none removes the tools and automatic analysis, not the conversation.

--ai-error-action repair opens a second session on the host, right after the analysis and in the AI repair state. The first of its tools acts on services: systemctl start, stop, restart or reset-failed on the units the run saw fail. This is the gesture to prefer: it is local and reversible. When it is not enough, the AI fixes the code (Repairing through code).

Fenêtre de terminal
just fleet-update --ai-error-action repair
  1. The grouped deterministic restart failed: the host stays in error.
  2. The AI analyses, in the AI analysis state, read-only.
  3. The AI repairs, in the AI repair state: it acts, then re-reads the failed units.
  4. Nothing failing anymore → the host resumes its course and joins the switch. Otherwise → the usual question, revert / keep / stop / rollback.
Guard-railEffect
UnitsOnly those the collection saw failing on this host; any other is refused
HostRefused if it is not currently being repaired: a read session never acts
AttemptsThree actions per host, refusals not counted; the fourth is refused
Stopping mid-runA run that stops repairs nothing: it is a new operation
ConfirmationIn interactive mode, a button question before each action: apply or skip

In non-interactive mode (night timer, --no-ui), the action passes without asking. It is strictly less risky than what the run already does without witness: the deterministic repair restarts all the host’s failed units.

Each action is counted, not just traced: it ends up in state.json and in the AI repair section of the report, refusals included, with its reason. A repaired host also carries a note in the report.

When no restart can help, the AI writes the fix into the project, validates it and commits it; the host is rebuilt then redeployed, and the rest of the fleet follows the commit (Align the fleet).

  1. edit_code replaces an exact passage (present only once), or rewrites a whole file. The git tree must be clean before the first edit, and the diff goes into logs/ai.log.
  2. validate runs the project cleanup, then re-evaluates and rebuilds that host alone, from the working trees: an uncommitted edit of dnf/ and a created file are seen there. An edit that does not change the host is reported.
  3. commit writes fix(<scope>): <sujet>, the scope naming what the fix touches (fix(nginx): …). In co-development, dnf/ is committed first, then the project and its lock realigned.
  4. The host goes back to built with the committed path; its wave serves it once more: copy, activation, conclusion.
SafeguardEffect
PathsThe project, and dnf/ in co-development; never usr/secrets/, .trash/, .git/, var/generated/, etc/config.yaml nor a *.lock
Outside co-developmentdnf/ is a store path: writing it is refused, and would have changed nothing
TreeDirty before the first edit → refused: a repair commit carries only the fix
AttemptsSix per host, one attempt per change: a service action, or the edits until the next validate. Validating and committing cost none
Validationcommit refused if the last edit is not validated: what is redeployed is what is committed
One commit per fixFixing again amends the fix commit of the fix, as long as it is at the head; never the chore(update) nor a human commit
One session at a timeRepairs run one after the other: a commit takes the whole tree
End of sessionUncommitted edit discarded, tree brought back to the last commit; the diff remains in logs/ai.log, and as a patch in logs/<hôte>.dnf.patch (or .consumer.patch) for git apply
HooksNever bypassed: the commit goes through the repository gate like any other
Messagednf/ is published: a framework commit that names a fleet host is refused

A build can fail because of the code: a package’s tests, a badly written option. With --ai-error-action ≠ none, the AI handles it at the end of the build, before the usual decision; built hosts wait.

  1. Hosts broken by the same error form one group: one session for all.
  2. The AI analyzes the group, in the AI analysis state, read-only.
  3. With repair, it fixes in the AI repair state, through the host that built the failing derivation: edit_code, validate (which rebuilds that host), commit.
  4. Fix committed → the fleet aligns, including the hosts of the group. Nothing committed → the usual decision: exclusion or stop.
CaseEffect
Known stop, exclude errorDecides alone, without AI
Failure outside the code (killed builder, network)Usual decision, without AI
Fleet evaluation failsNothing to attribute, no session
All hosts brokenRepair attempted before the no host built stop
--build-onlyRepairs too

Everything the launch publishes and activates comes from a single revision, the last commit. A fix may require several hosts to move together (a server and its clients): each repair commit realigns the fleet.

  1. All hosts still in the launch are re-evaluated at the last commit, in a single evaluation.
  2. Only those whose path changes are rebuilt; the others do not move.
  3. Host not yet served by the step → its wave serves it, new path included. Host already served → served again in a final pass of the step, same phase.

A host that the alignment breaks goes to the decision, never to a new repair. A host can also remain behind:

CaseThe host
Rebuild fails, in wavesKeeps its generation and its path
Unreachable at the final passReturns to its previous state and path
Commit during the final passNo more alignment after it

The fleet then runs on two revisions: the report and the incident room say so, with the hosts concerned (see Report and Matrix alerts). --resume reuses the aligned paths; cut before the alignment, it rebuilds everything.

With --ai-analysis active, the launch ends with a review of its warnings, and of what the repairs left to a human: renamed or deprecated option, a change that would silence a warning, a problem to investigate, a limit of the repair tool. The AI proposes, it changes neither the code nor the fleet.

  1. The warnings from all launch logs are grouped by shape: the same one on ten hosts counts once. No warning or repair → no review, nothing is paid.
  2. The AI reads the suggestions already filed and the conclusions of the repairs, then searches the code for where each warning comes from.
  3. Each useful finding becomes a file var/deployments/suggestions/<slug>.md: what, where (fichier:ligne), why, and the proposed improvement.
  4. The Suggestions section of the report lists what the launch filed or reviewed. Nothing is sent to Matrix: this is not an alert.

The files survive across launches. A finding that comes back does not rewrite its file: only the Last seen and Runs lines of the header move.

var/deployments/suggestions/nginx-deprecated-option.md
# Replace a deprecated nginx option
- Status: open
- First seen: 20260101T020000Z-full
- Last seen: 20260108T020000Z-full
- Runs: 4
The option is deprecated upstream: `usr/modules/web.nix:12`, …
ToDo
Silence a suggestionWrite Status: ignored in its header: it stays tracked, out of the report
Forget itDelete the file: a finding that comes back starts from scratch
Apply itFix the code, then delete the file

Scope follows the mode: in co-development, the project and dnf/; otherwise, the project alone (a finding that only the framework fixes is not filed).

Each launch writes its folder in var/deployments/<date>-<mode>/: report.md (the report), state.json (the state that --resume resumes), events.jsonl and the per-host logs. The path is displayed at the end of the launch.

The report details what the launch actually did:

SectionWhat it gives
Steps, WavesDuration of each step, composition and duration of each wave
BuildersWho built what, fallbacks included
CopiesPer host: paths pulled and by which substituter, paths pushed, volume
Zones without a cacheLaunch zones that no harmonia serves
Hosts not deployedHosts left aside, and the reason
DiagnosticsPer failing host: failed units, then error excerpt
NotesWhat the launch found: probable activation order after a unit restart
AI analysisAI analysis: one entry per analyzed host, then the launch synthesis
AI repairAI actions: host, action, outcome, and the reason for a refusal
SuggestionsImprovement suggestions filed or reviewed by the launch, excluding ignored ones
Known errorsTraps recognized by the signature table, in plain language

The header lists the launch commits, an amended fix counted (amended 2×). After a repair commit, it says whether the fleet is aligned:

FleetHeader line
AlignedRepaired by commit: <hôte>, fleet aligned on it
On two revisionsRepaired by commit: <hôte>, fleet on two revisions — <raisons>

The --send-report option sends this report to the channels of the alerts bot, installed beforehand by just configure-alert-bot.

SituationChannelContent
Launch finishedwarningsSummary: hosts by state, duration, known errors
Critical hosts not deployedincidentsSeparate message: hosts concerned, reasons and failed units
Fleet on two revisionsincidentsHosts behind, and why
Stop on errorincidentsError that stopped the launch, then summary

A host is critical when its profile appears in criticalProfiles. After a stop, the hosts left in test complete the incident message: a restart would bring them back to their previous generation.

Only the end-of-launch synthesis joins the message, never the per-host analyses, and it is limited there to six lines: beyond that, the message points to report.md. An alert channel is not a report.

The message repeats the report header, the exit code in the title:

**Fleet Update Report** (1)
Error: srv-maison: activation failed
- Started at 2026-09-17 02:00:00 UTC, duration: 4m12s
- Options: full run, selection all, test skipped, 10 in parallel
- Hosts: 5 deployed (hcs, gw-maison, pc-maison, gw-atelier, lt-atelier), 1 failed (srv-maison)
- Run stopped on error

On the deployment host, the module installs the tool and, with timer.enable, runs fleet-update --no-ui every day :

# usr/machines/<hôte>/configuration.nix
darkone.admin.fleet-update = {
enable = true;
user = "admin";
aiContext = "Répondre en français et rester concis.";
timer.enable = true;
};
OptionDefaultRole
usernoneProject owner: git, age key, AI, Matrix
workDir/etc/nixosConsumer project on disk
aiContextnullContext added to the AI prompts of every run on the host, written to /etc/fleet-update/ai-context, even without enable ; --ai-context overrides it
timer.onCalendar*-*-* 04:00Run time
timer.extraArgs[ ]Options added to --no-ui, --send-report for example
timer.timeout6hMaximum duration of a run

Two services combine to avoid recompiling or re-downloading derivations on every deployment.

ServiceRole
harmoniaServes the local, signed /nix/store directly to hosts (LAN, or VPN if global).
nix-cachePer-zone nginx proxy that caches the public cache.nixos.org cache on the gateway.

A harmonia host has a second role : it is the elected builder for its zone, because it knows how to serve what it builds.

A host queries these sources in the following priority order. The first retrieval from the Internet is thus shared across the whole zone.

PrioritySourceScope
20Zone’s harmoniaLAN, what the zone has compiled
35Zone’s nix-cache proxyLAN, shared mirror of the public cache
40Direct cache.nixos.orgSafety net if the gateway is down
45global harmoniaLast resort, over the VPN

At installation, just install hands the host’s caches to the installer when the target address belongs to a zone’s network.

Outside a zone (public IP, router LAN) and for any gateway (its zone caches go through it), the installer queries only cache.nixos.org : the rest comes from the administration workstation.

Fetching a package and building it are two distinct needs. The binary cache above covers the first. For the second, a powerful host of the network can take on the long compilations of an administrative host.

Declare it with the build-farm feature:

etc/config.yaml
features: ["build-farm"]

Each administrative host then adds it to its nix.buildMachines, joined over SSH by the deployment account nix. Nothing else to configure: the key and the authorization are already in place across the whole fleet.