feat(just): add fleet-status recipe #72

Merged
nimmo merged 2 commits from feat/fleet-status into main 2026-07-19 12:19:10 +01:00
Owner

Summary

Adds just fleet-status — a developer-facing command that probes every host in nixosConfigurations over SSH and renders a tabular view of Nix metadata: current generation, running revision (+ specialisation), divergence vs origin/main, and deployed timestamp. Offline hosts render as (unreachable). Beszel remains the source for liveness / CPU / RAM, so this recipe deliberately does not duplicate that data.

Closes #66

Implementation

  • New fleet-status recipe in justfiles/hosts.just, grouped alongside inventory.
  • One git fetch origin main at the top, then parallel SSH probes (one per host, & + wait, 5s connect timeout, -F /dev/null matching just deploy).
  • Per-host probe runs nixos-version --json, readlink /nix/var/nix/profiles/system, [ -r ] /etc/nixos-specialisation, and stat -c %y /…/system in a single ssh call. Failure at any point → (unreachable) cells.
  • Diff cell convention (per user preference, aligned with the bash-it theme): +N ahead of origin/main, -N behind, (clean) when equal, appends dirty when the revision carries a -dirty suffix. Both ahead and behind → +A -B.
  • Wire format uses | as the delimiter so empty specialisation fields don't shift columns (bash IFS=$'\t' collapses runs of whitespace).
  • README updated with a usage paragraph next to the existing just inventory docs.

Live validation evidence

Recipe run against the actual fleet immediately before this MR was opened:

HOST     GEN  REVISION        DIFF     DEPLOYED
electra  589  3665e21 (igpu)  (clean)  2026-07-19 07:01:52
lena     —    (unreachable)   —        (unreachable)
lyra     118  3665e21         (clean)  2026-07-19 06:01:08
vega     246  4d2061a         -11      2026-07-18 10:04:48
  • electra is on 3665e21 (matches origin/main) with the igpu specialisation → (clean) and (igpu) rendered correctly.
  • lena is offline (laptop asleep) → (unreachable) cells render as designed.
  • vega is at 4d2061a, 11 commits behind origin/main → -11 in the diff cell.

nix flake check passes against the four host configurations.

Out of scope (deferred per the issue's follow-up spec)

  • Role / purpose column.
  • Last-seen / uptime metrics.
  • Per-host flags, JSON output mode.

These can be added later without breaking the default output.

## Summary Adds `just fleet-status` — a developer-facing command that probes every host in `nixosConfigurations` over SSH and renders a tabular view of Nix metadata: current generation, running revision (+ specialisation), divergence vs `origin/main`, and deployed timestamp. Offline hosts render as `(unreachable)`. Beszel remains the source for liveness / CPU / RAM, so this recipe deliberately does not duplicate that data. Closes #66 ## Implementation - New `fleet-status` recipe in `justfiles/hosts.just`, grouped alongside `inventory`. - One `git fetch origin main` at the top, then parallel SSH probes (one per host, `&` + `wait`, 5s connect timeout, `-F /dev/null` matching `just deploy`). - Per-host probe runs `nixos-version --json`, `readlink /nix/var/nix/profiles/system`, `[ -r ] /etc/nixos-specialisation`, and `stat -c %y /…/system` in a single ssh call. Failure at any point → `(unreachable)` cells. - Diff cell convention (per user preference, aligned with the bash-it theme): `+N` ahead of `origin/main`, `-N` behind, `(clean)` when equal, appends `dirty` when the revision carries a `-dirty` suffix. Both ahead and behind → `+A -B`. - Wire format uses `|` as the delimiter so empty specialisation fields don't shift columns (bash `IFS=$'\t'` collapses runs of whitespace). - README updated with a usage paragraph next to the existing `just inventory` docs. ## Live validation evidence Recipe run against the actual fleet immediately before this MR was opened: ``` HOST GEN REVISION DIFF DEPLOYED electra 589 3665e21 (igpu) (clean) 2026-07-19 07:01:52 lena — (unreachable) — (unreachable) lyra 118 3665e21 (clean) 2026-07-19 06:01:08 vega 246 4d2061a -11 2026-07-18 10:04:48 ``` - electra is on `3665e21` (matches `origin/main`) with the `igpu` specialisation → `(clean)` and `(igpu)` rendered correctly. - lena is offline (laptop asleep) → `(unreachable)` cells render as designed. - vega is at `4d2061a`, 11 commits behind `origin/main` → `-11` in the diff cell. `nix flake check` passes against the four host configurations. ## Out of scope (deferred per the issue's follow-up spec) - Role / purpose column. - Last-seen / uptime metrics. - Per-host flags, JSON output mode. These can be added later without breaking the default output.
Adds 'just fleet-status' that probes every host in nixosConfigurations
over SSH and renders a tabular Nix-metadata view: hostname, current
generation, running revision (+ specialisation), divergence vs
origin/main, and deployed timestamp. Offline hosts show as
'(unreachable)'. Beszel remains the source for liveness/CPU/RAM.

Closes #66
nimmo left a comment

Required before merge: git fetch origin main updates FETCH_HEAD, but does not reliably refresh the origin/main ref read immediately afterward. This can silently calculate divergence using stale data. Please fetch the remote-tracking ref (git fetch --prune origin) or explicitly map main to refs/remotes/origin/main, then update the recipe’s validation evidence.

**Required before merge:** `git fetch origin main` updates `FETCH_HEAD`, but does not reliably refresh the `origin/main` ref read immediately afterward. This can silently calculate divergence using stale data. Please fetch the remote-tracking ref (`git fetch --prune origin`) or explicitly map `main` to `refs/remotes/origin/main`, then update the recipe’s validation evidence.
nimmo left a comment

Required refinement before merge: refresh origin/main before calculating divergence.

Required refinement before merge: refresh `origin/main` before calculating divergence.
Author
Owner

Required before merge: git fetch origin main updates FETCH_HEAD, but does not reliably refresh the origin/main ref read immediately afterward. This can silently calculate divergence using stale data. Please fetch the remote-tracking ref (git fetch --prune origin) or explicitly map main to refs/remotes/origin/main, then update the recipe’s validation evidence.

**Required before merge:** `git fetch origin main` updates `FETCH_HEAD`, but does not reliably refresh the `origin/main` ref read immediately afterward. This can silently calculate divergence using stale data. Please fetch the remote-tracking ref (`git fetch --prune origin`) or explicitly map `main` to `refs/remotes/origin/main`, then update the recipe’s validation evidence.
Switch from 'git fetch origin main' to 'git fetch --prune origin' so all
remote-tracking branches — including origin/main — are refreshed in one
operation. The narrower form can leave origin/main stale in rare refspec
configurations, causing the divergence count to silently read old data.

Addresses MR #72 review feedback.
Author
Owner

Addressed in commit 00d40d2 (pushed to feat/fleet-status).

Change: switched the upstream refresh in fleet-status from git fetch origin main to git fetch --prune origin (no refspec). The narrower form updates FETCH_HEAD but can leave origin/main stale in some refspec configurations; the broader form refreshes all remote-tracking branches in one operation, so git rev-parse origin/main after the fetch is guaranteed to read fresh data.

Updated live validation evidence:

HOST     GEN  REVISION        DIFF     DEPLOYED
electra  589  3665e21 (igpu)  (clean)  2026-07-19 07:01:52
lena     —    (unreachable)   —        (unreachable)
lyra     118  3665e21         (clean)  2026-07-19 06:01:08
vega     246  4d2061a         -11      2026-07-18 10:04:48

Fleet state is unchanged (vega still at 4d2061a, 11 commits behind origin/main; electra and lyra match 3665e21). nix flake check still passes.

Addressed in commit `00d40d2` (pushed to `feat/fleet-status`). **Change:** switched the upstream refresh in `fleet-status` from `git fetch origin main` to `git fetch --prune origin` (no refspec). The narrower form updates `FETCH_HEAD` but can leave `origin/main` stale in some refspec configurations; the broader form refreshes all remote-tracking branches in one operation, so `git rev-parse origin/main` after the fetch is guaranteed to read fresh data. **Updated live validation evidence:** ``` HOST GEN REVISION DIFF DEPLOYED electra 589 3665e21 (igpu) (clean) 2026-07-19 07:01:52 lena — (unreachable) — (unreachable) lyra 118 3665e21 (clean) 2026-07-19 06:01:08 vega 246 4d2061a -11 2026-07-18 10:04:48 ``` Fleet state is unchanged (vega still at `4d2061a`, 11 commits behind `origin/main`; electra and lyra match `3665e21`). `nix flake check` still passes.
nimmo merged commit db9d4a06e5 into main 2026-07-19 12:19:10 +01:00
nimmo deleted branch feat/fleet-status 2026-07-19 12:19:11 +01:00
Sign in to join this conversation.
No reviewers
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
nimmo/nixos-config!72
No description provided.