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
+43 -14
View File
@@ -43,9 +43,23 @@ var (
// releaseOf is the release (26.11) of a version like 26.11.20261027.31ecbac.
func releaseOf(version string) string { return releaseRe.FindString(version) }
// UpgradeCheck is check.json: the channel's newest revision against the running one.
// RouterCheck is what the repository has: its newest release tag against the
// installed version of nixos-router.
type RouterCheck struct {
Repository string `json:"repository"`
Installed string `json:"installed"`
Newest struct {
Tag string `json:"tag"`
Version string `json:"version"`
Rev string `json:"rev"`
} `json:"newest"`
Newer bool `json:"newer"`
}
// UpgradeCheck is check.json: the newest nixos-router and the channel's newest
// nixpkgs revision, against the installed and the running ones.
type UpgradeCheck struct {
Channel string `json:"channel"`
Channel string `json:"channel"` // "" if no channel is followed
Branch string `json:"branch"`
Time string `json:"time"`
Running struct {
@@ -55,7 +69,17 @@ type UpgradeCheck struct {
Newest struct {
Rev string `json:"rev"`
} `json:"newest"`
UpToDate bool `json:"upToDate"`
PackagesUpToDate bool `json:"packagesUpToDate"`
UpToDate bool `json:"upToDate"` // both
Router *RouterCheck `json:"router"` // nil if the repository could not be read
}
// RouterChange is the update of nixos-router that a preview includes.
type RouterChange struct {
From string `json:"from"`
To string `json:"to"`
Tag string `json:"tag"`
Rev string `json:"rev"`
}
// UpgradeChange is a package that has another version in the new system.
@@ -76,6 +100,7 @@ type UpgradePreview struct {
Builds int `json:"builds"`
BuildNames []string `json:"buildNames"` // what would be built here
RebootNeeded bool `json:"rebootNeeded"`
Router *RouterChange `json:"router"` // nixos-router changes too
Changes []UpgradeChange `json:"changes"`
}
@@ -154,13 +179,15 @@ var upgradeTitles = map[string]string{
type channelChoice struct{ Value, Label string }
type upgradeData struct {
Version string // the running NixOS version
Channel string
Choices []channelChoice
Check *UpgradeCheck
Preview *UpgradePreview
Run UpgradeRun
Title string // what the running step does
Router Release // the installed nixos-router
Repository string // where its releases come from
Version string // the running NixOS version
Channel string
Choices []channelChoice
Check *UpgradeCheck
Preview *UpgradePreview
Run UpgradeRun
Title string // what the running step does
NewerRelease string // a stable release newer than the followed channel exists
ReleasesSeen string // when the channel server was last asked which exist
@@ -263,7 +290,8 @@ func channelChoices(current string, stable []string) []channelChoice {
}
func (a *app) upgradeData() upgradeData {
d := upgradeData{Version: a.sys.runningVersion(), Run: a.sys.UpgradeStatus()}
d := upgradeData{Version: a.sys.runningVersion(), Run: a.sys.UpgradeStatus(),
Router: a.sys.installedRelease(), Repository: a.sys.repository()}
d.Updating = a.sys.UpdateStatus().Running
d.Pending = a.sys.Status().RollbackIn > 0
if s, err := loadSettings(a.sys.settingsPath()); err == nil {
@@ -287,7 +315,8 @@ func (a *app) upgradeData() upgradeData {
// What was checked before another channel was chosen or before the last
// upgrade says nothing about now; nor does a preview that another
// nixos-router made (it may list packages differently).
if readUpgradeFile(filepath.Join(a.sys.upgradeDir(), "check.json"), &c) && c.Channel == d.Channel && c.Running.Version == d.Version {
if readUpgradeFile(filepath.Join(a.sys.upgradeDir(), "check.json"), &c) && c.Channel == d.Channel && c.Running.Version == d.Version &&
(c.Router == nil || c.Router.Installed == a.sys.installedRelease().Version) {
d.Check = &c
}
var p UpgradePreview
@@ -344,8 +373,8 @@ func (a *app) upgradeStep(w http.ResponseWriter, r *http.Request, _ session) {
return
}
d := a.upgradeData()
if d.Channel == "" {
a.upgradeBack(w, r, "Choose a channel first.")
if d.Channel == "" && d.Repository == "" {
a.upgradeBack(w, r, "Choose a channel first: this router has no repository to look at either.")
return
}
if (action == "download" || action == "apply") && d.Preview == nil {