One upgrade for nixos-router and the packages

Check, preview and apply look at the repository's release tags and the
channel together; the new nixos-router is a highlighted row in the
preview table. The update server section and the separate git update
are gone; bundles stay.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 11:49:57 +01:00
co-authored by Claude Sonnet 5.5
parent 3e6eee0b9c
commit 2b7cd86e98
15 changed files with 372 additions and 695 deletions
+13 -77
View File
@@ -1,35 +1,16 @@
package main
import (
"net/http"
"net/url"
"os"
"path/filepath"
"regexp"
"strings"
)
// Updates from a git repository: router-update check looks at the
// repository's release tags (vX.Y.Z) once a day and when the page asks, and
// writes what it found to update/check.json; installing builds the router
// from a tag, like an update from a bundle. The repository is part of the
// installed version (routerUpdate.repository, written to
// /etc/router-update-repository), not something the page sets.
var releaseTagRe = regexp.MustCompile(`^v[0-9]+\.[0-9]+\.[0-9]+$`)
// GitCheck is update/check.json: the newest release tag of the repository.
type GitCheck struct {
Repository string `json:"repository"`
Time string `json:"time"`
Installed string `json:"installed"`
Newest struct {
Tag string `json:"tag"`
Version string `json:"version"`
Rev string `json:"rev"`
} `json:"newest"`
Newer bool `json:"newer"`
}
// nixos-router is an input of the configuration flake like nixpkgs, and comes
// from a git repository whose tags vX.Y.Z are releases. Looking for it and
// locking it is router-upgrade's, with the packages (check.json has both). The
// repository is part of the installed version (routerUpdate.repository,
// written to /etc/router-update-repository), not something the page sets.
// repository is where releases come from ("" if the router has none).
func (s System) repository() string {
@@ -41,60 +22,15 @@ func (s System) repository() string {
return strings.TrimSpace(string(data))
}
const gitCheckUnit = "router-update-check.service"
// gitCheck is what the last check found, if it is still about this repository
// and this installed version.
func (a *app) gitCheck() *GitCheck {
var c GitCheck
repository := a.sys.repository()
if repository == "" || !readUpgradeFile(filepath.Join(a.sys.updateDir(), "check.json"), &c) {
return nil
}
if c.Repository != repository || c.Installed != a.sys.installedRelease().Version || c.Newest.Tag == "" {
return nil
}
return &c
}
// newRouterVersion is the version of a release that is out and not installed,
// for the Overview ("" if there is none or nothing was checked).
// newRouterVersion is the version of a release of nixos-router that is out and
// not installed, for the Overview ("" if there is none or nothing was checked).
func (a *app) newRouterVersion() string {
if c := a.gitCheck(); c != nil && c.Newer {
return c.Newest.Version
var c UpgradeCheck
if !readUpgradeFile(filepath.Join(a.sys.upgradeDir(), "check.json"), &c) {
return ""
}
if r := c.Router; r != nil && r.Newer && r.Installed == a.sys.installedRelease().Version {
return r.Newest.Version
}
return ""
}
func (a *app) updateGitCheck(w http.ResponseWriter, r *http.Request, _ session) {
if a.sys.repository() == "" {
a.updateBack(w, r, "This router has no repository to look at.")
return
}
if err := startUnit(gitCheckUnit); err != nil {
a.updateBack(w, r, "Could not look: "+err.Error())
return
}
a.updateBack(w, r, "Looking at the repository.")
}
func (a *app) updateGitInstall(w http.ResponseWriter, r *http.Request, _ session) {
if a.busy() {
a.updateBack(w, r, "Another change is in progress or waiting for confirmation.")
return
}
tag := r.PostFormValue("tag")
if tag != "" && !releaseTagRe.MatchString(tag) {
a.updateBack(w, r, "Not a release tag: "+url.QueryEscape(tag))
return
}
if a.sys.repository() == "" {
a.updateBack(w, r, "This router has no repository to update from.")
return
}
if err := a.sys.requestUpdate("git", tag, r.PostFormValue("force") == "on"); err != nil {
a.updateBack(w, r, "Could not start the update: "+err.Error())
return
}
a.updateBack(w, r, "Updating.")
}