From 9cb2d28ea1beadbb83ec85009dfc94e4cc64768a Mon Sep 17 00:00:00 2001 From: Nils Stinnesbeck Date: Tue, 24 Nov 2026 22:55:54 +0100 Subject: [PATCH] Put the Update and Packages pages on one Updates page Router software and packages are two parts of one page, with one overlay, one confirmation banner and both logs. /upgrade redirects to it; the actions keep their addresses. Co-Authored-By: Claude Sonnet 5.5 --- SPECS.md | 24 +++- pkgs/router-webui/main.go | 4 +- pkgs/router-webui/static/style.css | 2 + pkgs/router-webui/templates/layout.html | 3 +- pkgs/router-webui/templates/overview.html | 2 +- pkgs/router-webui/templates/update.html | 167 +++++++++++++++++++--- pkgs/router-webui/templates/upgrade.html | 130 ----------------- pkgs/router-webui/update.go | 34 +++-- pkgs/router-webui/upgrade.go | 11 +- pkgs/router-webui/upgrade_test.go | 29 +++- tests/apply.nix | 17 +-- 11 files changed, 231 insertions(+), 192 deletions(-) delete mode 100644 pkgs/router-webui/templates/upgrade.html diff --git a/SPECS.md b/SPECS.md index d101187..f4d49e2 100644 --- a/SPECS.md +++ b/SPECS.md @@ -234,7 +234,7 @@ Upgrading nixpkgs (the kernel and every package) on the router, without a new re - **`download`**: fetches and builds it (needs 3 GiB free), so a flaky uplink does not matter at `apply`. - **`apply [timeout]`**: takes the previewed lock into the configuration directory and runs `router-apply` (commit-confirm). The directory as it was is kept in `config.pre-update` like for updates: a rollback or a failed build puts the lock back. Refused if the configuration flake changed since the preview. - **Pin**: `nixpkgs-pin.json` in the configuration directory (channel, revision, flake reference with `narHash`). `router-update` locks it again after it installs a new release of nixos-router, so a release does not undo an upgrade; the reference is found in the store by its hash, offline. -- **Web UI page** `/upgrade` ("Packages", under System): the channel as a select (none, `unstable`, and the stable releases in `stableChannels` in `upgrade.go`, 26.05 for now, until the router can ask the channel server which exist: the running release says nothing, since nixos-unstable already calls itself the next one; a configured channel that is none of these stays listed; saved to `settings.json` and the confirmed settings, so it never shows as unapplied), buttons Check, Preview (with "look anyway" when up to date), Download now and Upgrade. The preview shows the version table, download size, local builds (a warning above 50) and a reboot note for a new kernel. The page asks for a step in `upgrade/request.json` and starts `router-upgrade.service`, which runs `router-upgrade --request` (not restarted or stopped by a switch, like `router-apply`); it shows `check.json`/`preview.json` (not those of another channel, nor a check from before the last upgrade) and `upgrade/last.log`, which the unit tees (a finished one-shot unit has no journal to find). Download and Upgrade need a preview and no change waiting for confirmation; a request without a `channel` field is refused rather than clearing it. +- **Web UI page** (since 0.13.2 the "Updates" page `/update`, the packages part at `#packages`; `GET /upgrade` redirects there, the `POST /upgrade/*` actions are unchanged; before, "Packages" was a page of its own): the channel as a select (none, `unstable`, and the stable releases in `stableChannels` in `upgrade.go`, 26.05 for now, until the router can ask the channel server which exist: the running release says nothing, since nixos-unstable already calls itself the next one; a configured channel that is none of these stays listed; saved to `settings.json` and the confirmed settings, so it never shows as unapplied), buttons Check, Preview (with "look anyway" when up to date), Download now and Upgrade. The preview shows the version table, download size, local builds (a warning above 50) and a reboot note for a new kernel. The page asks for a step in `upgrade/request.json` and starts `router-upgrade.service`, which runs `router-upgrade --request` (not restarted or stopped by a switch, like `router-apply`); it shows `check.json`/`preview.json` (not those of another channel, nor a check from before the last upgrade) and `upgrade/last.log`, which the unit tees (a finished one-shot unit has no journal to find). Download and Upgrade need a preview and no change waiting for confirmation; a request without a `channel` field is refused rather than clearing it. - **Module options** (for tests): `routerSettings.upgrade.channelsUrl`, `routerSettings.upgrade.nixpkgsRef` (`%rev%`). - **Test** (`apply`): the channel is a small HTTP server on the client that redirects like channels.nixos.org, and the "newer" nixpkgs is the installed one under a `path:` reference with the same `lastModified` and `rev`: a really different nixpkgs cannot be built offline (any version change rebuilds the NixOS tools). Covers check, preview (including the package-list rules), download, an unconfirmed upgrade rolled back with its lock and pin, a confirmed one, and a failing build. @@ -284,6 +284,24 @@ On the user's own router (settings and infrastructure, not code) 5. **Web UI and remote access** — pages for every setting, themes, MCP server, REST API. *Done* (0.12.0); see "Not done yet". Package upgrades (see above) -- **New NixOS release**: look for newer `nixos-YY.MM` branches and say so; mark releases the installed nixos-router was not tested with. -- **Tested revisions**: a signed manifest in the release naming the nixpkgs revisions the tests passed on, as a gate in front of the channel's tip. +- **New NixOS release**: *done in 0.13.1* (the notice and the channel list). Still open: mark releases the installed nixos-router was not tested with. +- **Tested revisions**: a signed manifest in the release naming the nixpkgs revisions the tests passed on, as a gate in front of the channel's tip (the "not tested" mark depends on it). - **Reset**: go back to the nixpkgs that came with the release (`channel = null` and remove the pin). +- **Real package changes in tests**: the upgrade tests use an identical nixpkgs copy, so no real version change is ever exercised. +- **Merge the Update and Packages pages, and take releases from git** (decided 2026-11-24, not built). The repository is public, so no key is needed on the router; trusting the git server (TLS and the tag) is enough, so no signatures on this path; the packages come from cache.nixos.org and the small parts of nixos-router are built on the router; gitea has to be reachable to update this way. Plan: + 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. `router.update.repository` (a git URL). A daily check (`git ls-remote --tags`, newest `vX.Y.Z`) shows "0.x.y is available" on the Overview, like the release notice. + 3. Preview and apply lock the configuration flake to the tag (`--override-input nixos-router git+?rev=…`) next to the nixpkgs pin, evaluate once and show the package changes, download and builds of both together; the serial guard and the settings migration run as for bundles. + 4. A release is a tag on the commit (`router-release` can still write a bundle for offline routers and the installer). The nixpkgs in the repository's `flake.lock` must be a revision of a channel (`git-revision`), so cache.nixos.org has its packages. + 5. VM test with a git server in the client VM (`git+http://`), as `channelServer` stands in for channels.nixos.org. + Bundles and `--url` stay (offline, installer, gitea down). + +Web UI polish (list of 2026-11-24) +- Folds inside panels (Packages "What is built here", WireGuard) may jump like the certificate log did. +- Other confirmations still use the browser's dialog, not the in-page box; tooltips (firewall headers) do not work on touch; the diff does not mark changed words. + +Monitoring +- Alert rules and a Grafana dashboard for the Prometheus metrics; per-LAN traffic. + +On the user's own router +- Apply the saved port 4001 forwards (to 192.168.168.254, tcp+udp) and check them end to end (a NodePort 30401 would need `toPort`); install 0.13.1 and look at the Prometheus page and the release notice. diff --git a/pkgs/router-webui/main.go b/pkgs/router-webui/main.go index 00abf3c..f10eef9 100644 --- a/pkgs/router-webui/main.go +++ b/pkgs/router-webui/main.go @@ -270,7 +270,7 @@ func newApp(sys System, metrics *Collector, dev bool) *app { func (a *app) parseTemplates() (map[string]*template.Template, error) { files := map[string][]string{"overview": {"templates/dashboard.html"}} pages := map[string]*template.Template{} - for _, page := range []string{"login", "overview", "network", "dhcp", "dns", "wireguard", "firewall", "ddns", "dnsproviders", "certificate", "exporter", "advanced", "update", "upgrade", "tokens", "changes"} { + for _, page := range []string{"login", "overview", "network", "dhcp", "dns", "wireguard", "firewall", "ddns", "dnsproviders", "certificate", "exporter", "advanced", "update", "tokens", "changes"} { t, err := template.New("layout.html").Funcs(a.funcs). ParseFS(assets, append([]string{"templates/layout.html", "templates/" + page + ".html"}, files[page]...)...) if err != nil { @@ -342,7 +342,7 @@ func (a *app) routes() http.Handler { mux.HandleFunc("POST /update/check", a.auth(a.updateCheck)) mux.HandleFunc("POST /update/install", a.auth(a.updateInstall)) mux.HandleFunc("POST /update/upload", a.updateUpload) - mux.HandleFunc("GET /upgrade", a.auth(a.upgradePage)) + mux.HandleFunc("GET /upgrade", a.auth(upgradeRedirect)) mux.HandleFunc("POST /upgrade/channel", a.auth(a.upgradeChannel)) mux.HandleFunc("POST /upgrade/{step}", a.auth(a.upgradeStep)) mux.HandleFunc("/mcp", a.mcp) diff --git a/pkgs/router-webui/static/style.css b/pkgs/router-webui/static/style.css index d8644d5..36e4530 100644 --- a/pkgs/router-webui/static/style.css +++ b/pkgs/router-webui/static/style.css @@ -52,6 +52,8 @@ main { padding: 1.5rem clamp(1rem, 3vw, 3rem) 3rem; } .cols { columns: 38rem 3; column-gap: 1.5rem; } .cols > section, .cols > fieldset, .cols > form > fieldset { break-inside: avoid; } .cols > section.busy, .cols > section.pending, .cols > section.notice { column-span: all; } +.cols > h2.part { column-span: all; margin: 1rem 0 .2rem; padding-bottom: .3rem; border-bottom: 1px solid var(--line); font-size: 1.1rem; } +.cols > h2.part:first-child { margin-top: 0; } /* A fold of its own (a log) sits below the columns: opening it must not make them balance again. */ .cols > details { column-span: all; break-inside: avoid; margin-top: 1rem; } .menu-toggle { position: absolute; opacity: 0; pointer-events: none; } diff --git a/pkgs/router-webui/templates/layout.html b/pkgs/router-webui/templates/layout.html index 628ae09..bcb25b7 100644 --- a/pkgs/router-webui/templates/layout.html +++ b/pkgs/router-webui/templates/layout.html @@ -29,8 +29,7 @@ Prometheus diff --git a/pkgs/router-webui/templates/overview.html b/pkgs/router-webui/templates/overview.html index 0f30955..012d67a 100644 --- a/pkgs/router-webui/templates/overview.html +++ b/pkgs/router-webui/templates/overview.html @@ -23,7 +23,7 @@ {{end}} {{with .Data.NewRelease}} -

NixOS {{.}} is out. See what it would change.

+

NixOS {{.}} is out. See what it would change.

{{end}}
diff --git a/pkgs/router-webui/templates/update.html b/pkgs/router-webui/templates/update.html index 00a3e18..786776f 100644 --- a/pkgs/router-webui/templates/update.html +++ b/pkgs/router-webui/templates/update.html @@ -1,31 +1,43 @@ {{define "content"}}
-{{$d := .Data}} -
-

Installed

-
-
Version
{{or $d.Installed.Version "unknown"}}{{if $d.Installed.Rev}} {{$d.Installed.Rev}}{{end}}
-
Settings schema
{{$d.Installed.Schema}}
-
-
+{{$u := .Data.Update}}{{$g := .Data.Upgrade}} -{{if $d.Status.Running}} +{{if $u.Status.Running}} -{{else if $d.Pending}} +{{else if $g.Run.Running}} + +{{else if $u.Pending}}

Waiting for confirmation

-

A new configuration is active and not confirmed yet. Confirm it on the Overview, or the router - goes back to the previous version.

+

A new system is active and not confirmed yet. Confirm it on the Overview, or the router goes back to the + previous one.

{{end}} +

Router software

+ +
+

Installed

+
+
Version
{{or $u.Installed.Version "unknown"}}{{if $u.Installed.Rev}} {{$u.Installed.Rev}}{{end}}
+
Settings schema
{{$u.Installed.Schema}}
+
+
+

Install a bundle

A .bundle file made with nix run .#release. It is installed only if it is signed with @@ -41,17 +53,17 @@

Update server

- +
- {{if $d.URL}} + {{if $u.URL}}
{{end}} - {{if $d.OfferErr}}

Could not check: {{$d.OfferErr}}

{{end}} - {{with $d.Offer}} + {{if $u.OfferErr}}

Could not check: {{$u.OfferErr}}

{{end}} + {{with $u.Offer}}

{{if .Newer}}Available: {{.Version}}{{if .Rev}} {{.Rev}}{{end}}.{{else}}Nothing newer: the server has {{.Version}}.{{end}}

@@ -63,10 +75,121 @@ nix run .#release writes. The data is signed, so plain HTTP works too.

-{{if and $d.Status.Log (not $d.Status.Running)}} +

Packages

+ +{{with $g.NewerRelease}} +
+

NixOS {{.}} is out

+

You follow {{$g.Channel}}. {{.}} is the newer stable release: switch the channel to it, then look for upgrades and + preview what would change. Nothing is installed until you upgrade, and NixOS cannot go back to the older release afterwards.

+ + + + + +
+{{end}} +
-

Last update{{if $d.Status.Result}} — {{if eq $d.Status.Result "success"}}succeeded{{else}}failed ({{$d.Status.Result}}){{end}}{{end}}

-
{{$d.Status.Log}}
+

Channel

+

Upgrades the kernel and all programs (NixOS) without a new release of nixos-router. Nothing is downloaded until + you ask for it, and an upgrade is activated like a settings change: unless you confirm it in time, the router + goes back to the previous system.

+
+
Running
{{or $g.Version "unknown"}}
+
+
+ + + +
+ {{if $g.ReleasesSeen}}

Stable releases as the channel server listed them on {{$g.ReleasesSeen}}; Check for upgrades asks again.

{{end}} +

The channel only chooses what an upgrade offers; saving it changes nothing on the router. Going back to an older release + (unstable to 26.05) is refused unless you tick "downgrade anyway" when previewing; state written by the newer + release may not work with the older one.

+
+ +{{if $g.Channel}} +
+

Check

+
+ + +
+ {{with $g.Check}} +
+
Channel
{{.Branch}}
+
Running
{{.Running.Version}}
+
Newest
{{printf "%.7s" .Newest.Rev}} checked {{.Time}}
+
+ {{if .UpToDate}}

Up to date.

{{else}}

A newer revision is available.

{{end}} + {{end}} +
+ +
+

What would change

+
+ + {{if and $g.Check $g.Check.UpToDate}}{{end}} + + +
+

Works it out from the new revision's description: no package is downloaded.

+ {{with $g.Preview}} +

{{$g.Version}} → {{.Version}} {{printf "%.7s" .Rev}}, previewed {{.Time}}

+ {{if .Changes}} + + + {{range .Changes}}{{end}} +
PackageNowNew
{{.Name}}{{.From}}→{{.To}}
+ {{else}}

No package changes.

{{end}} +

The list shows the versions of programs the router runs; a program that is only rebuilt does not appear.

+
+
To download
{{or .Download "nothing, or the package cache cannot be reached"}}
+
Built here
{{.Builds}} derivation{{if ne .Builds 1}}s{{end}}{{if gt .Builds 50}} (many: the package cache may not have them yet; this takes long){{end}}
+ {{if .RebootNeeded}}
Kernel
A new kernel: it runs after the next reboot.
{{end}} +
+ {{if .BuildNames}} +
+ What is built here +

The system's own pieces (they carry the nixpkgs revision) and programs the package cache does not have yet.

+
    {{range .BuildNames}}
  • {{.}}
  • {{end}}
+ {{if .MoreBuilds}}

… and {{.MoreBuilds}} more

{{end}} +
+ {{end}} +
+
+ + +
+
+ + Upgrade to {{.Version}} + +
+

Downloading first lets you start the upgrade later without needing the internet. Upgrading + downloads what is missing, builds the system and switches to it; confirm it on the Overview.

+ {{end}} +
+{{else}} +

Choose a channel to look for upgrades.

+{{end}} + +{{if and $u.Status.Log (not $u.Status.Running)}} +
+

Last update{{if $u.Status.Result}} — {{if eq $u.Status.Result "success"}}succeeded{{else}}failed ({{$u.Status.Result}}){{end}}{{end}}

+
{{$u.Status.Log}}
+
+{{end}} + +{{if and $g.Run.Log (not $g.Run.Running)}} +
+

Last package run{{if $g.Run.Result}} — {{if eq $g.Run.Result "success"}}succeeded{{else}}failed ({{$g.Run.Result}}){{end}}{{end}}

+
{{$g.Run.Log}}
{{end}}
diff --git a/pkgs/router-webui/templates/upgrade.html b/pkgs/router-webui/templates/upgrade.html deleted file mode 100644 index 16f2df7..0000000 --- a/pkgs/router-webui/templates/upgrade.html +++ /dev/null @@ -1,130 +0,0 @@ -{{define "content"}} -
-{{$d := .Data}} -
-

Packages

-

Upgrades the kernel and all programs (NixOS) without a new release of nixos-router. Nothing is downloaded until - you ask for it, and an upgrade is activated like a settings change: unless you confirm it in time, the router - goes back to the previous system.

-
-
Running
{{or $d.Version "unknown"}}
-
-
- - - -
- {{if $d.ReleasesSeen}}

Stable releases as the channel server listed them on {{$d.ReleasesSeen}}; Check for upgrades asks again.

{{end}} -

The channel only chooses what an upgrade offers; saving it changes nothing on the router. Going back to an older release - (unstable to 26.05) is refused unless you tick "downgrade anyway" when previewing; state written by the newer - release may not work with the older one.

-
- -{{with $d.NewerRelease}} -
-

NixOS {{.}} is out

-

You follow {{$d.Channel}}. {{.}} is the newer stable release: switch the channel to it, then look for upgrades and - preview what would change. Nothing is installed until you upgrade, and NixOS cannot go back to the older release afterwards.

-
- - - -
-
-{{end}} - -{{if $d.Updating}} -

Updating…

The router is installing a new version of nixos-router.

-{{else if $d.Run.Running}} - -{{else if $d.Pending}} -

Waiting for confirmation

-

A new system is active and not confirmed yet. Confirm it on the Overview, or the router goes back to the - previous one.

-{{end}} - -{{if $d.Channel}} -
-

Check

-
- - -
- {{with $d.Check}} -
-
Channel
{{.Branch}}
-
Running
{{.Running.Version}}
-
Newest
{{printf "%.7s" .Newest.Rev}} checked {{.Time}}
-
- {{if .UpToDate}}

Up to date.

{{else}}

A newer revision is available.

{{end}} - {{end}} -
- -
-

What would change

-
- - {{if and $d.Check $d.Check.UpToDate}}{{end}} - - -
-

Works it out from the new revision's description: no package is downloaded.

- {{with $d.Preview}} -

{{$d.Version}} → {{.Version}} {{printf "%.7s" .Rev}}, previewed {{.Time}}

- {{if .Changes}} - - - {{range .Changes}}{{end}} -
PackageNowNew
{{.Name}}{{.From}}→{{.To}}
- {{else}}

No package changes.

{{end}} -

The list shows the versions of programs the router runs; a program that is only rebuilt does not appear.

-
-
To download
{{or .Download "nothing, or the package cache cannot be reached"}}
-
Built here
{{.Builds}} derivation{{if ne .Builds 1}}s{{end}}{{if gt .Builds 50}} (many: the package cache may not have them yet; this takes long){{end}}
- {{if .RebootNeeded}}
Kernel
A new kernel: it runs after the next reboot.
{{end}} -
- {{if .BuildNames}} -
- What is built here -

The system's own pieces (they carry the nixpkgs revision) and programs the package cache does not have yet.

-
    {{range .BuildNames}}
  • {{.}}
  • {{end}}
- {{if .MoreBuilds}}

… and {{.MoreBuilds}} more

{{end}} -
- {{end}} -
-
- - -
-
- - Upgrade to {{.Version}} - -
-

Downloading first lets you start the upgrade later without needing the internet. Upgrading - downloads what is missing, builds the system and switches to it; confirm it on the Overview.

- {{end}} -
-{{else}} -

Choose a channel to look for upgrades.

-{{end}} - -{{if and $d.Run.Log (not $d.Run.Running)}} -
-

Last run{{if $d.Run.Result}} — {{if eq $d.Run.Result "success"}}succeeded{{else}}failed ({{$d.Run.Result}}){{end}}{{end}}

-
{{$d.Run.Log}}
-
-{{end}} -
-{{end}} diff --git a/pkgs/router-webui/update.go b/pkgs/router-webui/update.go index 7593a96..fc6dec9 100644 --- a/pkgs/router-webui/update.go +++ b/pkgs/router-webui/update.go @@ -289,15 +289,31 @@ func (a *app) updateData() updateData { return d } +// updatesData is the Updates page: the router software (a release of +// nixos-router) and the packages (nixpkgs) on one page. +type updatesData struct { + Update updateData + Upgrade upgradeData +} + +func (a *app) updatesData() updatesData { + return updatesData{Update: a.updateData(), Upgrade: a.upgradeData()} +} + func (a *app) updatePage(w http.ResponseWriter, r *http.Request, sess session) { - d := a.updateData() - p := page{Title: "Update", CSRF: sess.csrf, LoggedIn: true, Data: d, Flash: r.URL.Query().Get("msg")} - if d.Status.Running { + d := a.updatesData() + p := page{Title: "Updates", CSRF: sess.csrf, LoggedIn: true, Data: d, Flash: r.URL.Query().Get("msg")} + if d.Update.Status.Running || d.Upgrade.Run.Running { p.Live = 3 } a.render(w, "update", p) } +// upgradeRedirect sends the old address of the packages part to the page. +func upgradeRedirect(w http.ResponseWriter, r *http.Request, _ session) { + http.Redirect(w, r, "/update#packages", http.StatusSeeOther) +} + func (a *app) updateBack(w http.ResponseWriter, r *http.Request, msg string) { http.Redirect(w, r, "/update?msg="+url.QueryEscape(msg), http.StatusSeeOther) } @@ -324,17 +340,17 @@ func (a *app) updateSaveURL(w http.ResponseWriter, r *http.Request, _ session) { } func (a *app) updateCheck(w http.ResponseWriter, r *http.Request, sess session) { - d := a.updateData() - p := page{Title: "Update", CSRF: sess.csrf, LoggedIn: true} - if d.URL == "" { + d := a.updatesData() + p := page{Title: "Updates", CSRF: sess.csrf, LoggedIn: true} + if d.Update.URL == "" { a.updateBack(w, r, "Set the update server first.") return } - offer, err := a.sys.checkUpdate(d.URL) + offer, err := a.sys.checkUpdate(d.Update.URL) if err != nil { - d.OfferErr = err.Error() + d.Update.OfferErr = err.Error() } else { - d.Offer = &offer + d.Update.Offer = &offer } p.Data = d a.render(w, "update", p) diff --git a/pkgs/router-webui/upgrade.go b/pkgs/router-webui/upgrade.go index 1d0f116..7570d78 100644 --- a/pkgs/router-webui/upgrade.go +++ b/pkgs/router-webui/upgrade.go @@ -294,17 +294,8 @@ func (a *app) upgradeData() upgradeData { return d } -func (a *app) upgradePage(w http.ResponseWriter, r *http.Request, sess session) { - d := a.upgradeData() - p := page{Title: "Packages", CSRF: sess.csrf, LoggedIn: true, Data: d, Flash: r.URL.Query().Get("msg")} - if d.Run.Running { - p.Live = 3 - } - a.render(w, "upgrade", p) -} - func (a *app) upgradeBack(w http.ResponseWriter, r *http.Request, msg string) { - http.Redirect(w, r, "/upgrade?msg="+url.QueryEscape(msg), http.StatusSeeOther) + http.Redirect(w, r, "/update?msg="+url.QueryEscape(msg)+"#packages", http.StatusSeeOther) } func (a *app) upgradeChannel(w http.ResponseWriter, r *http.Request, _ session) { diff --git a/pkgs/router-webui/upgrade_test.go b/pkgs/router-webui/upgrade_test.go index 2d7ec50..5d8e5aa 100644 --- a/pkgs/router-webui/upgrade_test.go +++ b/pkgs/router-webui/upgrade_test.go @@ -37,6 +37,25 @@ func TestReleaseOfAndChannelChoices(t *testing.T) { } } +func TestOneUpdatesPage(t *testing.T) { + a, _ := newTestApp(t) + h := a.routes() + cookie := login(t, h) + // The old address of the packages leads to the page that has both parts. + if rec := do(h, "GET", "/upgrade", nil, cookie); rec.Code != http.StatusSeeOther || rec.Header().Get("Location") != "/update#packages" { + t.Fatalf("/upgrade: %d %q", rec.Code, rec.Header().Get("Location")) + } + body := do(h, "GET", "/update", nil, cookie).Body.String() + for _, want := range []string{"Router software", "Install a bundle", "Update server", `id="packages"`, "Choose a channel", `aria-current="page">Updates`} { + if !strings.Contains(body, want) { + t.Errorf("the page lacks %q", want) + } + } + if strings.Contains(body, `href="/upgrade"`) { + t.Error("the menu still links /upgrade") + } +} + func TestReleaseNotice(t *testing.T) { seen := []string{"25.05", "25.11", "26.05", "26.11"} if got := supportedReleases(seen); strings.Join(got, ",") != "26.05,26.11" { @@ -69,16 +88,16 @@ func TestReleaseNoticeShows(t *testing.T) { } h := a.routes() cookie := do(h, "POST", "/login", url.Values{"password": {"hunter2hunter2"}}, nil).Result().Cookies()[0] - if body := do(h, "GET", "/upgrade", nil, cookie).Body.String(); strings.Contains(body, "is out") { + if body := do(h, "GET", "/update", nil, cookie).Body.String(); strings.Contains(body, "is out") { t.Fatalf("a notice before the channel server was asked:\n%s", body) } os.WriteFile(filepath.Join(sys.upgradeDir(), "releases.json"), []byte(`{"time":"2026-11-19T00:00:00Z","releases":["26.05","26.11"]}`), 0o644) - for _, path := range []string{"/", "/upgrade"} { + for _, path := range []string{"/", "/update"} { if body := do(h, "GET", path, nil, cookie).Body.String(); !strings.Contains(body, "NixOS 26.11 is out") { t.Errorf("%s has no notice:\n%s", path, body) } } - if body := do(h, "GET", "/upgrade", nil, cookie).Body.String(); !strings.Contains(body, `