From 7957d88ff9a97eca25a603e77f661b808f6979af Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Wed, 2 Dec 2026 18:38:37 -0600 Subject: [PATCH] fixup! feat(status): a status page, for the phone of whoever looks after the box install the app in /usr/local/lib/pdtv26-status, not in the state directory: with DynamicUser, systemd makes /var/lib/pdtv26-status its own symlink to /var/lib/private, and the service failed at STATE_DIRECTORY ("File exists"). The package's check now catches a unit that runs a program from its own StateDirectory. Generated-by: Claude Opus 5.5 --- status/Makefile | 2 +- status/default.nix | 8 +++++++- status/pdtv26-status.service | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/status/Makefile b/status/Makefile index 1ab7d67..5a4fab7 100644 --- a/status/Makefile +++ b/status/Makefile @@ -14,7 +14,7 @@ SPEECH = localhost:8024 BRAIN = localhost:8025 # The private network's addresses: the only ones it answers or checks. A tailnet's, by default. RANGES = 100.64.0.0/10 fd7a:115c:a1e0::/48 -APP = /var/lib/pdtv26-status/app +APP = /usr/local/lib/pdtv26-status/app UNIT = /etc/systemd/system/pdtv26-status.service TARGETS = /etc/pdtv26-status/targets diff --git a/status/default.nix b/status/default.nix index c26a259..5e9c838 100644 --- a/status/default.nix +++ b/status/default.nix @@ -6,7 +6,7 @@ stdenvNoCC.mkDerivation { version = "0.1.0"; src = lib.fileset.toSource { root = ./.; - fileset = lib.fileset.unions [ ./status.js ./status.test.js ./status-server.js ]; + fileset = lib.fileset.unions [ ./status.js ./status.test.js ./status-server.js ./pdtv26-status.service ]; }; nativeCheckInputs = [ nodejs-slim ]; doCheck = true; @@ -14,6 +14,12 @@ stdenvNoCC.mkDerivation { runHook preCheck node --check status-server.js node --test + # With DynamicUser, systemd makes /var/lib/ its own symlink, so nothing else + # can live there: the app (make install's GC root) goes elsewhere. + state=$(sed -n 's/^StateDirectory=//p' pdtv26-status.service) + if grep -q "^ExecStart=/var/lib/$state/" pdtv26-status.service; then + echo "pdtv26-status.service runs a program from its own StateDirectory, /var/lib/$state" >&2; exit 1 + fi runHook postCheck ''; installPhase = '' diff --git a/status/pdtv26-status.service b/status/pdtv26-status.service index 2040012..b94aad3 100644 --- a/status/pdtv26-status.service +++ b/status/pdtv26-status.service @@ -8,7 +8,7 @@ Wants=network-online.target # speech server, and the brain's channel; make install writes them, host:port, to the targets file. # The private network is the boundary: no key. EnvironmentFile=/etc/pdtv26-status/targets -ExecStart=/var/lib/pdtv26-status/app/bin/status-server :: ${PORT} /var/lib/pdtv26-status ${NAME} ${BOX} ${SPEECH} ${BRAIN} +ExecStart=/usr/local/lib/pdtv26-status/app/bin/status-server :: ${PORT} /var/lib/pdtv26-status ${NAME} ${BOX} ${SPEECH} ${BRAIN} DynamicUser=yes StateDirectory=pdtv26-status IPAddressDeny=any