The settings only allow paths in the state directory, which is 0700 root and which HAProxy (a user of its own) cannot enter. systemd reads the files and gives the service copies; a path unit restarts it when one changes. The load balancer test keeps its files in the state directory now, and verifies the backends' certificate.
7.6 KiB
Handover (state at release 0.14.0, 2026-11-27)
For an agent picking up nixos-router. Read DEVELOPING.md (how to build and test) and SPECS.md (what exists and
what is open) first; this file is what is not obvious from them.
State
- Branch
installed-webui, last release commitRelease 0.14.0, tagv0.14.0, both pushed.mainis the PR base. Releases since the unified upgrade (0.13.7): 0.13.8 (fix below), 0.14.0 (load balancers). - Unstaged, deliberately untouched: the mode change of
scripts/webui-dev.sh. It makes the release script print "built from a tree that differs from HEAD". dist/router-update-0.14.0.bundle(1.4 GB, signed) is the only bundle; delete the old one after each release.- Nothing is half-done. 0.14.0 passed the Go tests,
fast,assertions,loadbalancerandwebui;applyandupdatepassed on the build just before the last change to the load balancer page (onlyloadbalancer.go), not on the final one. - Not yet tried: the git path against the real gitea (the VM test serves its own repository from the builder), and load balancers on the user's real router (they want one for an API on hv1/hv2; they add it in Advanced).
0.13.8: names that became static (leasesdns.go)
router-webui leases-dns publishes DHCP clients' names in Unbound. When Unbound restarted it removed, by name, what
it had published before, which also removed the configuration's record if the name had become a reservation or a
dns.hosts entry in that same apply (hv1/hv2). It now stores the Unbound's pid with the status and forgets
(does not remove) what an older Unbound had (stillThere). Test: TestNewUnboundForgetsWhatTheOldOneHad.
Load balancers (0.14.0)
router.loadBalancers.<name> (options in modules/router/options.nix, HAProxy config in
modules/router/loadbalancer.nix, port opening in firewall.nix as lbInput, assertions in assertions.nix as
lbAssertions). The full description is the "Load balancers" section of SPECS.md. Things that were not obvious:
- IPv4 and IPv6 are bound apart (
bind 0.0.0.0:Pandbind :::P v6only): a dual-stack socket shows IPv4 clients as::ffff:a.b.c.dinX-Forwarded-For. - NixOS's own
services.haproxyassertion forces the whole config text, so the generator must never fail on a bad setting (an unresolved backend is skipped there; our assertion reports it). - The
addrcolumn ofshow statis empty. The web UI (loadbalancer.go) reads addresses fromshow servers state(srv_addr,srv_port). TheloadbalancerVM test checks that the real HAProxy has the columns the page reads; keep it when upgrading HAProxy. - Certificates and CA files live in
/var/lib/router(0700 root), which HAProxy cannot enter: they go in throughLoadCredentialand the config names/run/credentials/haproxy.service/…(fileOf). A path unit restarts HAProxy when a file changes. 0.14.0 lacked this (fixed after the release; see the git log). - The stats socket is the NixOS module's
/run/haproxy/haproxy.sock;System.HAProxySocketoverrides it in tests. - A service's
hostsbecomerouter.dns.hostsentries (mkDefault) pointing at the router's address in the LANs it listens in; that is how inside and outside use one name. - Untested: the PROXY protocol,
balance = source,backendTls.verify, shared ports in a VM, the router's own ACME certificate for a service. Open: a settings form (services are edited in Advanced), backend state in/metricsand MCP, UDP, taking a backend out of service from the page.
How an upgrade works now (0.13.7)
nixos-router is an input of the configuration flake next to nixpkgs; one upgrade moves both.
modules/settings/upgrade.nix(router-upgrade):checkreads the channel's nixpkgs revision and the repository's newestvX.Y.Ztag (git ls-remote) into/var/lib/router/upgrade/check.json.previewfetches the tag (nix flake prefetch), builds a "release dir" from the source (version, serial = commit time, schema = number ofmigrations/*.jq), writes the flake fromconfig-flake.nix(@SOURCE@replaced withgit+<repo>?ref=refs/tags/vX&rev=<commit>), migrates the settings in a copy, locks it, and diffs packages intopreview.json(router: {from,to,tag,rev}when nixos-router changes too).applysnapshots, copies flake + migrated settings + lock,router-applywith commit-confirm; rollback restoresconfig.pre-update.dailyis what the timer runs.modules/settings/update.nix(router-update): only signed bundles (--bundle,--url,--request, web upload). The repository optionrouterUpdate.repository(default the real gitea) is a module option, not a setting; a test or a fork overrides it inlocal.nix.nulldisables the repository.- Web UI (
pkgs/router-webui):upgrade.go(types,/upgrade/{check,preview,download,apply,channel}),update.go(bundle upload, progress),gitupdate.go(repository file, Overview notice),templates/update.html(the one page). Pages are Go templates with a strict CSP: no inline styles or handlers. config-flake.nixis a contract with every installed updater: change it only compatibly.
Rules that cost time before
- Run VM tests one at a time:
nix run .#test -- <name>(webui ~2 min, apply ~16, update ~14, assertions ~5). Parallel runs OOM'd the machine. New files needgit add -Nfirst.nix flake check --no-builderrors on these tests for unrelated reasons. - Edit files with the Edit/Write tools, not sed/python through Bash (the user asked for this).
- Git commit messages and PR descriptions get no attribution lines (the user's latest instruction).
- An assertion test (
tests/assertions.nix) compares the exact number of failed assertions per case, so a case must trigger only the assertion it is about. - Do not commit, release, push or delete bundles until the user says so. The user's phrasing: "commit and release it as
X.Y.Z when the tests pass", then "yes push it and delete the old bundle". A release is a feature commit, then a
Release X.Y.Zcommit bumpingVERSION, thennix run .#release -- --key ~/.config/nixos-router/update.sec(builds the bundle and creates the annotated tag; push the tag explicitly:git push origin <branch> vX.Y.Z). The user's git signs tags, so tags need-a -m; the release script does that. - Use
jq, not bash substitution, to put the source address into the flake (&is special in bash 5.2 replacements). - Nix against a git input needs
--option flake-registry "", or it tries to download the global registry. - Waiting loops in tests must stop at
failedand use a short ceiling (300 s); the user objected to 900 s. - Transient systemd-run units cannot be restarted: start a new one.
Open items (all in SPECS.md, "Not done yet")
- Release script: refuse a
flake.lockwhose nixpkgs is not a channel revision (so cache.nixos.org has the packages). - "Reset to the release's nixpkgs" action; signed manifest / "not tested with this version" mark.
- Real package changes in upgrade tests (they use an identical nixpkgs copy).
- Web UI polish: folds that may jump, browser confirm dialogs, touch tooltips, word-level diff.
- Load balancers: a settings form, backend state in
/metricsand MCP, UDP, drain/maintenance from the page; tidy the indentation of the generated HAProxy config (cosmetic). - API
applyscope for tokens, more MCP read tools; WireGuard live status; host-based routing 80/443, IPv6, multi-WAN/QoS; Prometheus alert rules and a Grafana dashboard. - The user's own router tasks: apply the saved port 4001 forwards to 192.168.168.254 (tcp+udp) and check, install this
release and try the real git path, public ports of antigua, narrow
familyrules.