Tag releases, and name the version on the Overview

nix run .#release ends by creating the annotated tag vX.Y.Z on the released
commit (the tags routers that update from the repository look for); it
refuses a HEAD of another version and does nothing outside a checkout. The
System card on the Overview says which nixos-router and NixOS run.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 10:37:14 +01:00
co-authored by Claude Sonnet 5.5
parent 3afd7ed4cc
commit 83343f7a18
6 changed files with 62 additions and 4 deletions
+1 -1
View File
@@ -292,7 +292,7 @@ Package upgrades (see above)
1. **Done (0.13.2):** one "Updates" page with the parts "Router software" and "Packages", one overlay and one confirmation banner, both logs. Still to do for it: one check, one preview and one apply for both (needs step 3).
2. **Done (0.13.3, fixed in 0.13.4):** the repository is hardcoded: the module option `routerUpdate.repository` (beside `routerUpdate.publicKeys`; not a `router.*` setting, so it is not in the settings, the options listing or the web UI) defaults to `https://git.stinnesbeck.com/nils/nixos-router`, is baked into `router-update` and written to `/etc/router-update-repository` for the web UI, and the page only names it (no field: a fork or a test sets the option in a module; a moved repository needs a bundle update). `router-update check` (daily timer `router-update-check`, and the page's button) lists the repository's tags with `git ls-remote`, takes the newest `vX.Y.Z` (other tags are ignored) and writes `update/check.json` (repository, time, installed, newest tag/version/revision, newer). The Overview and the Updates page show it while it is about this repository and the installed version.
3. **Done (0.13.3), without a preview:** `router-update --git TAG|latest` (the web UI's "Install"): `nix flake prefetch` of `git+<repo>?ref=refs/tags/<tag>&rev=<commit>`, then the steps of a bundle update from the serial guard on (snapshot, flake, nixpkgs pin, migration, `router-apply` with commit-confirm, rollback). The flake is the source's `config-flake.nix` with `@SOURCE@` replaced by that address, so `flake.lock` and `flake.nix` agree and nothing moves by itself (this file is a contract with every updater already installed: change it only compatibly). The release data (version, serial = the commit's time, schema = the number of `migrations/*.jq`) is read from the fetched source. No signature is checked. Still to do: preview (package changes, download and builds of both inputs), and the nixpkgs-pin interplay for a pin chosen later.
4. Still to do: a release is a tag `vX.Y.Z` on the release commit (`router-release` tags it, still writes a bundle for the installer and offline routers) and refuses a `flake.lock` whose nixpkgs is not a channel revision (`git-revision`), so cache.nixos.org has its packages.
4. **Tag: done (0.13.5).** A release is a tag `vX.Y.Z` on the release commit: `nix run .#release` (which still writes the bundle for the installer and offline routers) ends by creating the annotated tag, locally (push it with the branch; `--no-tag` skips it). It refuses when HEAD's `VERSION` is another version or the tag is on another commit, does nothing outside a git checkout (the VM tests), and tags last so a failed release leaves no tag. Still to do: refuse a `flake.lock` whose nixpkgs is not a channel revision (`git-revision`), so cache.nixos.org has its packages.
5. **Done:** the `update` VM test serves a repository from the builder (`common.gitServer`: `git http-backend` over HTTP) and covers the check, tags that are no releases, refused tags, install through the web UI with migration, confirm, the rebuild without the server, and "not newer".
Bundles and `--url` stay (offline, installer, gitea down).
+1
View File
@@ -222,6 +222,7 @@
name = "router-release";
runtimeInputs = with pkgs; [
nix
git
gnutar
coreutils
jq
+4 -1
View File
@@ -319,6 +319,8 @@ type dashboard struct {
Events []Event
Charts []Chart
Prefs Prefs
Version string // the installed release of nixos-router
NixOS string // the NixOS it runs on
}
func (a *app) dashboardData(rangeName string) dashboard {
@@ -326,7 +328,8 @@ func (a *app) dashboardData(rangeName string) dashboard {
now := time.Now()
s, _ := loadSettings(a.sys.settingsPath())
f := s.form()
d := dashboard{Range: rg.Name, Interval: 5, Snap: a.metrics.Snapshot(), Prefs: a.sys.loadPrefs()}
d := dashboard{Range: rg.Name, Interval: 5, Snap: a.metrics.Snapshot(), Prefs: a.sys.loadPrefs(),
Version: a.sys.installedRelease().Version, NixOS: a.sys.runningVersion()}
// Newest first, the last few.
ev := d.Snap.Uplink.Events
d.Events = make([]Event, 0, 10)
+19
View File
@@ -155,6 +155,25 @@ func TestDashboardRenders(t *testing.T) {
}
}
func TestDashboardNamesTheVersion(t *testing.T) {
a, sys := newTestApp(t)
dir := t.TempDir()
sys.ReleaseFile = filepath.Join(dir, "router-release")
sys.VersionFile = filepath.Join(dir, "nixos-version")
os.WriteFile(sys.ReleaseFile, []byte(`{"version":"4.5.6"}`), 0o600)
os.WriteFile(sys.VersionFile, []byte("26.11.20261113.d5cc683\n"), 0o600)
a.sys = sys
h := a.routes()
cookie := login(t, h)
// The page and the fragment that refreshes it say what runs.
for _, path := range []string{"/", "/dashboard?range=24h"} {
body := do(h, "GET", path, nil, cookie).Body.String()
if !strings.Contains(body, "nixos-router 4.5.6") || !strings.Contains(body, "NixOS 26.11.20261113.d5cc683") {
t.Errorf("%s does not name the version:\n%s", path, body)
}
}
}
func TestBackup(t *testing.T) {
a, sys := newTestApp(t)
h := a.routes()
@@ -32,6 +32,7 @@
<section class="card">
<h2>System</h2>
<dl>
{{if $d.Version}}<dt>Version</dt><dd>nixos-router {{$d.Version}}{{if $d.NixOS}} <span class="muted">on NixOS {{$d.NixOS}}</span>{{end}}</dd>{{end}}
<dt>Uptime</dt><dd>{{age $sys.Uptime}}</dd>
{{if $sys.Kernel}}<dt>Kernel</dt><dd>{{$sys.Kernel}}{{if $sys.KernelNext}} <span class="bad">reboot to run {{$sys.KernelNext}}</span> <button type="button" class="link" data-dialog="Reboot the router now? Routing stops for a minute or two." data-dialog-ok="Reboot" data-post="/reboot">Reboot</button>{{end}}</dd>{{end}}
{{if $sys.BootPending}}<dt>Reboot</dt><dd><span class="bad">a new configuration starts at the next reboot</span> <button type="button" class="link" data-dialog="Reboot the router now? Routing stops for a minute or two." data-dialog-ok="Reboot" data-post="/reboot">Reboot</button></dd>{{end}}
+36 -2
View File
@@ -1,16 +1,23 @@
# Signs $release (a store path) as a binary cache and writes, into --out:
# router-update-<version>.bundle one file to upload in the web UI
# latest, cache/ the same, laid out for `router pulls from a URL`
# usage: router-release --key KEYFILE [--out DIR] [--compression zstd|none]
#
# Run in a git checkout it also tags the commit that was released (vX.Y.Z, the
# tags routers that update from the repository look for). The tag is local: it
# has to be pushed with the branch. It is made last, so a release that fails
# leaves no tag.
# usage: router-release --key KEYFILE [--out DIR] [--compression zstd|none] [--no-tag]
key=""
out=dist
compression=zstd
tag=1
while [ $# -gt 0 ]; do
case $1 in
--key) key=$2; shift ;;
--out) out=$2; shift ;;
--compression) compression=$2; shift ;;
*) echo "usage: router-release --key KEYFILE [--out DIR] [--compression zstd|none]" >&2; exit 2 ;;
--no-tag) tag=0 ;;
*) echo "usage: router-release --key KEYFILE [--out DIR] [--compression zstd|none] [--no-tag]" >&2; exit 2 ;;
esac
shift
done
@@ -28,3 +35,30 @@ tar -C "$out" -cf "$out/router-update-$version.bundle" latest cache
echo "release $version ($(du -h "$out/router-update-$version.bundle" | cut -f1)):"
echo " upload $out/router-update-$version.bundle in the router's web UI (Update)"
echo " or serve $out over HTTP(S) and give the router that URL"
if [ "$tag" -eq 1 ]; then
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo " tag none: not in a git repository"
else
head_version=$(git show HEAD:VERSION 2>/dev/null | tr -d '\n' || true)
if [ "$head_version" != "$version" ]; then
echo "router-release: the commit at HEAD is version '$head_version', not $version: not tagged" >&2
echo " (commit the version, then: git tag -a v$version -m 'Release $version')" >&2
exit 1
fi
head=$(git rev-parse HEAD)
if git rev-parse -q --verify "refs/tags/v$version" >/dev/null; then
if [ "$(git rev-parse "v$version^{commit}")" != "$head" ]; then
echo "router-release: v$version is already a tag of another commit" >&2
exit 1
fi
echo " tag v$version exists"
else
git tag -a "v$version" -m "Release $version"
echo " tag v$version on ${head:0:7}: push it with the branch (git push origin v$version)"
fi
if [ "$(cat "$release/rev")" != "$head" ]; then
echo " note the release was built from a tree that differs from HEAD (uncommitted changes)"
fi
fi
fi