{ lib, buildNpmPackage, importNpmLock, nodejs_22, esbuild, # bug-tv's static web package; overridden here so the site talks to the /tv URL mapping bugTvWeb, }: let web = bugTvWeb.override { apiBase = "/tv"; }; src = lib.fileset.toSource { root = ../.; fileset = lib.fileset.unions [ (lib.fileset.difference ../activity (lib.fileset.maybeMissing ../activity/dist)) ../scripts/build-activity.sh ../package.json ../package-lock.json ]; }; pkgJson = lib.importJSON ../package.json; in buildNpmPackage { pname = "bug-tv-discord-activity"; inherit (pkgJson) version; inherit src; nodejs = nodejs_22; # same lockfile as the server; @discord/embedded-app-sdk is resolved from node_modules by esbuild npmDeps = importNpmLock { npmRoot = src; }; npmConfigHook = importNpmLock.npmConfigHook; # npm's esbuild needs its postinstall binary download; nixpkgs' esbuild is used instead npmFlags = [ "--ignore-scripts" ]; # the whole bug.tv site + discord.js (SDK + party transport) + overlay.css buildPhase = '' runHook preBuild ESBUILD=${lib.getExe esbuild} bash scripts/build-activity.sh ${web} site runHook postBuild ''; installPhase = '' runHook preInstall cp -r site $out runHook postInstall ''; passthru = { inherit web; }; meta = { description = "bug.tv Discord Activity: the bug.tv site with the watch-party overlay (static files)"; homepage = "https://git.bug.tools/bug/tv-discord"; platforms = lib.platforms.all; }; }