Hardcode the repository releases come from

routerUpdate.repository (a module option beside the update keys, not a
router.* setting) defaults to the project's repository; the Updates page names
it but no longer has a field for it. Forks and tests set it in a module.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 10:05:08 +01:00
co-authored by Claude Sonnet 5.5
parent 6982ae4d73
commit ad9de15344
11 changed files with 85 additions and 101 deletions
+22 -6
View File
@@ -63,8 +63,8 @@ let
text = ''
usage() {
echo "usage: router-update check | [--force] (--request | --bundle FILE | --url URL | --git TAG|latest) [timeout]" >&2
echo " check the newest release tag of router.update.repository, against the installed version" >&2
echo " --git TAG build the release from a tag (vX.Y.Z, or latest) of router.update.repository" >&2
echo " check the newest release tag of the repository, against the installed version" >&2
echo " --git TAG build the release from a tag (vX.Y.Z, or latest) of the repository" >&2
echo " --bundle FILE a bundle made by router-release" >&2
echo " --url URL a server with the release's latest and cache/ (HTTP or HTTPS)" >&2
echo " --request what the web UI asked for (${updateDir}/request.json)" >&2
@@ -98,7 +98,7 @@ let
# The release tags of the repository, "TAG REVISION" per line (an
# annotated tag counts with the commit it points to).
repository() { jq -r '.router.update.repository // empty' "$config/settings.json"; }
repository() { echo ${lib.escapeShellArg (toString config.routerUpdate.repository)}; }
git_tags() {
git ls-remote --tags "$1" 'refs/tags/v*' | awk '
{ n = $2; sub("^refs/tags/", "", n); peeled = (n ~ /\^\{\}$/); sub(/\^\{\}$/, "", n)
@@ -112,7 +112,7 @@ let
# Only looks: no lock, so it runs beside an update.
repo=$(repository)
if [ -z "$repo" ]; then
echo "router-update: no repository (router.update.repository): nothing to look at"
echo "router-update: this router has no repository: nothing to look at"
exit 0
fi
tags=$(git_tags "$repo") || die "cannot read the tags of $repo"
@@ -170,7 +170,7 @@ let
if [ "$mode" = git ]; then
repo=$(repository)
[ -n "$repo" ] || die "no repository: set router.update.repository"
[ -n "$repo" ] || die "this router has no repository to update from"
tags=$(git_tags "$repo") || die "cannot read the tags of $repo"
if [ -z "$arg" ] || [ "$arg" = latest ]; then
found=$(tail -n 1 <<<"$tags")
@@ -268,6 +268,20 @@ in
default = null;
description = "Version, serial, revision and settings schema of this nixos-router (`/etc/router-release`).";
};
routerUpdate.repository = lib.mkOption {
type = lib.types.nullOr (lib.types.strMatching "https?://[A-Za-z0-9.-]+(:[0-9]+)?(/[A-Za-z0-9._~/-]*)?");
default = "https://git.stinnesbeck.com/nils/nixos-router";
example = "https://git.example.org/me/nixos-router";
description = ''
The public git repository of nixos-router whose tags `vX.Y.Z` are
releases. `router-update check` (daily, and in the web UI) looks for a
newer tag, and `router-update --git` builds the router from it, like an
update from a bundle. The repository is trusted (TLS and the tag),
nothing is signed on this path. It belongs to the installed version, not
to the settings: a fork or a test sets it in a module. null: updates
come from bundles and update servers only.
'';
};
routerUpdate.publicKeys = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
@@ -284,6 +298,8 @@ in
if config.routerSettings.release == null then { } else config.routerSettings.release
);
environment.etc."router-update-keys".text = lib.concatLines keys;
# For the web UI.
environment.etc."router-update-repository".text = toString config.routerUpdate.repository;
environment.systemPackages = [
update
restore
@@ -305,7 +321,7 @@ in
router.rollback.onRollback = "${restore}/bin/router-update-restore";
router.rollback.onConfirm = "rm -rf ${snapshot}";
# Is there a newer release in router.update.repository? Once a day, and when
# Is there a newer release in the repository? Once a day, and when
# the web UI asks. It only reads the repository's tag list.
systemd.services.router-update-check = {
description = "Look for a newer release of nixos-router";