Follow the channel server's redirect and offer the stable releases

channels.nixos.org answers <branch>/git-revision with a redirect, which
router-upgrade check did not follow: on a real router it saw an empty
answer. The test channel is now an HTTP server that redirects the same way.

The page labelled the running release "stable", but nixos-unstable already
calls itself the next release (26.11 does not exist as a branch yet). It
offers none, unstable and the stable releases listed in the code (26.05).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AeFqV9dZrK6nipHkPfyM4F
This commit is contained in:
2026-11-08 23:28:47 +01:00
co-authored by Claude Sonnet 5.5
parent f4a192d416
commit 3d5ec77f57
5 changed files with 56 additions and 23 deletions
+29 -3
View File
@@ -42,13 +42,13 @@ let
);
# Only so the test driver can talk to the installed system; the channel is a
# directory, and a newer nixpkgs a copy of the installed one (made below).
# server on the client, and a newer nixpkgs a copy of the installed one (made below).
local = pkgs.writeText "local.nix" ''
{ modulesPath, ... }:
{
imports = [ (modulesPath + "/testing/test-instrumentation.nix") ];
routerSettings.upgrade = {
channelsUrl = "file:///tmp/channels";
channelsUrl = "http://192.168.10.50:8080";
nixpkgsRef = "path:/var/lib/newer-nixpkgs?lastModified=${toString self.inputs.nixpkgs.lastModified}&rev=%rev%";
};
}
@@ -63,6 +63,26 @@ let
modules = [ "${configDir}/local.nix" ];
}).config.system.build.toplevel;
channelServer = pkgs.writeScript "channels.py" ''
#!${pkgs.python3}/bin/python3
import http.server
class Handler(http.server.SimpleHTTPRequestHandler):
def __init__(self, *args, **kwargs):
super().__init__(*args, directory="/srv/channels", **kwargs)
def do_GET(self):
parts = self.path.strip("/").split("/")
if len(parts) == 2 and parts[1] == "git-revision":
self.send_response(302)
self.send_header("Location", "/files/" + self.path.strip("/"))
self.end_headers()
else:
super().do_GET()
http.server.ThreadingHTTPServer(("0.0.0.0", 8080), Handler).serve_forever()
'';
sharedDisk = {
virtualisation.diskImage = "./target.qcow2";
virtualisation.diskSize = 8192;
@@ -99,6 +119,9 @@ pkgs.testers.runNixOSTest {
prefixLength = 24;
}
];
# channels.nixos.org: <branch>/git-revision is a redirect to the file.
networking.firewall.allowedTCPPorts = [ 8080 ];
environment.etc."channels.py".source = channelServer;
};
target = {
@@ -326,8 +349,11 @@ pkgs.testers.runNixOSTest {
running_version = target.succeed("cat /run/current-system/nixos-version")
running_rev = "${self.inputs.nixpkgs.rev}"
client.succeed("mkdir -p /srv/channels/files/nixos-26.05 && systemd-run --unit=channels /etc/channels.py")
client.wait_for_open_port(8080)
def channel(rev):
target.succeed(f"mkdir -p /tmp/channels/nixos-26.05 && printf %s {rev} > /tmp/channels/nixos-26.05/git-revision")
client.succeed(f"printf %s {rev} > /srv/channels/files/nixos-26.05/git-revision")
with subtest("router-upgrade check needs a channel and a reachable revision"):
rc, out = target.execute("router-upgrade check 2>&1")