# 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/ 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 ''; }