The Activity is now the full bug.tv site plus a small Discord overlay. Whoever starts the instance hosts and controls everything; everyone else mirrors the host's page and playback. The server is a relay keyed by activity instance and checks membership through Discord's activity-instances API, so it works in DM and group calls. The bot gateway, slash commands and control message are gone.
71 lines
1.8 KiB
Nix
71 lines
1.8 KiB
Nix
{
|
|
lib,
|
|
buildNpmPackage,
|
|
importNpmLock,
|
|
nodejs_22,
|
|
makeWrapper,
|
|
# linked to lib/bug-tv-discord/activity, config.js's default activityDir
|
|
activity ? null,
|
|
}:
|
|
|
|
let
|
|
nodejs = nodejs_22;
|
|
|
|
src = lib.fileset.toSource {
|
|
root = ../.;
|
|
fileset = lib.fileset.unions [
|
|
../src
|
|
../package.json
|
|
../package-lock.json
|
|
];
|
|
};
|
|
|
|
pkgJson = lib.importJSON ../package.json;
|
|
in
|
|
|
|
buildNpmPackage {
|
|
pname = "bug-tv-discord";
|
|
inherit (pkgJson) version;
|
|
inherit src nodejs;
|
|
|
|
# deps are fetched per-package from package-lock.json, no hash to keep in sync
|
|
npmDeps = importNpmLock { npmRoot = src; };
|
|
npmConfigHook = importNpmLock.npmConfigHook;
|
|
|
|
# esbuild's postinstall is only needed for the activity bundle (built with pkgs.esbuild)
|
|
npmFlags = [ "--ignore-scripts" ];
|
|
dontNpmBuild = true;
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
# the activity SDK and esbuild are dev deps; the server only needs its runtime deps
|
|
npm prune --omit=dev --ignore-scripts --offline --no-audit --no-fund
|
|
find node_modules -mindepth 1 -maxdepth 1 -type d -empty -delete
|
|
|
|
mkdir -p $out/lib/bug-tv-discord
|
|
cp -r src package.json $out/lib/bug-tv-discord/
|
|
if [ -d node_modules ]; then cp -r node_modules $out/lib/bug-tv-discord/; fi
|
|
|
|
makeWrapper ${lib.getExe nodejs} $out/bin/bug-tv-discord \
|
|
--add-flags $out/lib/bug-tv-discord/src/index.js \
|
|
--set-default NODE_ENV production
|
|
'' + lib.optionalString (activity != null) ''
|
|
ln -s ${activity} $out/lib/bug-tv-discord/activity
|
|
'' + ''
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
passthru = { inherit activity; };
|
|
|
|
meta = {
|
|
inherit (pkgJson) description;
|
|
homepage = "https://git.bug.tools/bug/tv-discord";
|
|
mainProgram = "bug-tv-discord";
|
|
platforms = lib.platforms.linux;
|
|
};
|
|
}
|