Update from a git repository

router.update.repository names a public repository whose tags vX.Y.Z are
releases. router-update check (daily, and from the Updates page) looks for a
newer one and the Overview says so; router-update --git builds the router
from a tag like a bundle update: the settings are migrated, the new version
must be confirmed, the nixpkgs pin stays. The flake of such a router comes
from the release's config-flake.nix. The global flake registry is off.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 08:57:00 +01:00
co-authored by Claude Sonnet 5.5
parent a2dbeb5dea
commit 3fc54e678e
13 changed files with 589 additions and 26 deletions
+46
View File
@@ -39,6 +39,52 @@
http.server.ThreadingHTTPServer(("0.0.0.0", 8080), Handler).serve_forever()
'';
# A git server over (smart) HTTP: `git http-backend` for the repositories under
# the directory in argv[1], on the port in argv[2]. Enough for ls-remote and fetch.
gitServer =
pkgs:
pkgs.writeScript "git-server.py" ''
#!${pkgs.python3}/bin/python3
import http.server, os, subprocess, sys
root, port = sys.argv[1], int(sys.argv[2])
class Handler(http.server.BaseHTTPRequestHandler):
def do_GET(self):
self.cgi()
def do_POST(self):
self.cgi()
def cgi(self):
path, _, query = self.path.partition("?")
body = self.rfile.read(int(self.headers.get("Content-Length") or 0))
env = dict(os.environ, GIT_PROJECT_ROOT=root, GIT_HTTP_EXPORT_ALL="1", PATH_INFO=path,
QUERY_STRING=query, REQUEST_METHOD=self.command, REMOTE_ADDR=self.client_address[0],
CONTENT_TYPE=self.headers.get("Content-Type", ""), CONTENT_LENGTH=str(len(body)),
HTTP_CONTENT_ENCODING=self.headers.get("Content-Encoding", ""))
done = subprocess.run(["${pkgs.git}/bin/git", "http-backend"], input=body, env=env, capture_output=True)
head, _, out = done.stdout.partition(b"\r\n\r\n")
status, headers = 200, []
for line in head.split(b"\r\n"):
name, _, value = line.decode().partition(": ")
if name.lower() == "status":
status = int(value.split()[0])
elif name:
headers.append((name, value))
self.send_response(status)
for name, value in headers:
self.send_header(name, value)
self.send_header("Content-Length", str(len(out)))
self.end_headers()
self.wfile.write(out)
def log_message(self, *args):
pass
http.server.ThreadingHTTPServer(("0.0.0.0", port), Handler).serve_forever()
'';
# `driverInteractive` uses the full QEMU, which would open a window per VM;
# `nix run .#lab` wants the consoles in the terminal instead.
interactiveDefaults.virtualisation.qemu.options = [