check / check (push) Canceled after 0s
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
34 lines
1.4 KiB
Nix
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
|
|
'';
|
|
}
|