Files
dckc 9b85deca8f feat(status): a status page, for the phone of whoever looks after the box
Is the box up, and speech, and the brain; how many conversations,
turns, IR presses, and looks, today and all time. Counts and times
only: no transcripts.

- status/status.js: what the events and checks add up to, and the page
- status/status-server.js: the page, the box's events and heartbeat,
  and a TCP check of each part every 30 s; events kept in a file
- status/pdtv26-status.service and Makefile: sudo make install on the
  home server, answering only the private network
- checks: status (its tests)

Generated-by: Claude Opus 5.5
2026-12-02 18:57:08 -06:00

34 lines
1.4 KiB
Nix

# The status page: bin/status-server HOST PORT STATE_DIR NAME BOX SPEECH BRAIN, with node.
# No npm dependencies: node's own http and net. The tests run as the package builds.
{ lib, stdenvNoCC, nodejs-slim }:
stdenvNoCC.mkDerivation {
pname = "pdtv26-status";
version = "0.1.0";
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [ ./status.js ./status.test.js ./status-server.js ./pdtv26-status.service ];
};
nativeCheckInputs = [ nodejs-slim ];
doCheck = true;
checkPhase = ''
runHook preCheck
node --check status-server.js
node --test
# With DynamicUser, systemd makes /var/lib/<StateDirectory> 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 = ''
runHook preInstall
mkdir -p $out/lib/pdtv26-status $out/bin
cp status.js status-server.js $out/lib/pdtv26-status/
printf '#!/bin/sh\nexec %s %s/lib/pdtv26-status/status-server.js "$@"\n' ${nodejs-slim}/bin/node $out > $out/bin/status-server
chmod +x $out/bin/status-server
runHook postInstall
'';
}