nixos/netboot: Fix installer update failures
CI / Check, build and cache nixfiles (push) Has been cancelled
Update docs / update (push) Has been cancelled
Installer / Build installer (push) Successful in 4m56s

`netboot-update` failed with an opaque curl usage error whenever the
`installer` tag advanced past a build that had not published assets:
the `jq` select found no matching asset, and the empty result was
passed straight to `curl` as the URL. Report the missing asset (and
an unresolvable tag) instead.

The unit also had its network dependency inverted, being `wantedBy`
network-online.target rather than wanting and ordering after it. Fix
the idiom and keep it in the boot transaction via multi-user.target.

On river that is not enough on its own, because the WAN is a pppd
interface that networkd's wait-online knows nothing about, so
network-online.target is reached well before there is a route
off-site. Gate the service on wan-online.target there, following the
same wantedBy + partOf idiom as ipsec, which also re-runs the fetch
whenever the link returns.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-18 23:21:31 +01:00
parent 41ada3fa60
commit d1b9358069
2 changed files with 20 additions and 2 deletions
+11 -2
View File
@@ -129,7 +129,8 @@ in
services = {
netboot-update = {
description = "Update netboot images";
after = [ "systemd-networkd-wait-online.service" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
serviceConfig.Type = "oneshot";
path = with pkgs; [
coreutils curl jq zstd gnutar
@@ -138,6 +139,10 @@ in
update_nixos() {
latestShort="$(curl -s https://git.nul.ie/api/v1/repos/dev/nixfiles/tags/installer \
| jq -r .commit.sha | cut -c -7)"
if [ -z "$latestShort" ] || [ "$latestShort" = "null" ]; then
echo "Couldn't resolve the installer tag to a commit" >&2
return 1
fi
if [ -f nixos-installer/tag.txt ] && [ "$(< nixos-installer/tag.txt)" = "$latestShort" ]; then
echo "NixOS installer is up to date"
return
@@ -148,6 +153,10 @@ in
fname="jackos-installer-netboot-$latestShort.tar.zst"
downloadUrl="$(curl -s https://git.nul.ie/api/v1/repos/dev/nixfiles/releases/tags/installer | \
jq -r ".assets[] | select(.name == \"$fname\").browser_download_url")"
if [ -z "$downloadUrl" ]; then
echo "No release asset $fname; did the installer build succeed?" >&2
return 1
fi
curl -Lo /tmp/nixos-installer-netboot.tar.zst "$downloadUrl"
tar -C nixos-installer --zstd -xf /tmp/nixos-installer-netboot.tar.zst
truncate -s "${cfg.server.installer.storeSize}" nixos-installer/rootfs.ext4
@@ -163,7 +172,7 @@ in
update_nixos
'';
startAt = "06:00";
wantedBy = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
};
nbd-server = {