{ lib, stdenvNoCC, nodejs_24, pnpm_11, pnpmConfigHook, fetchPnpmDeps, makeWrapper, }: let nodejs = nodejs_24; pnpm = pnpm_11; packageJson = lib.importJSON ./package.json; in stdenvNoCC.mkDerivation (finalAttrs: { pname = "streamplace-bot"; inherit (packageJson) version; src = lib.fileset.toSource { root = ./.; fileset = lib.fileset.unions [ ./package.json ./pnpm-lock.yaml ./src ]; }; # Shared with frontend.nix: both derivations read the same pnpm-lock.yaml pnpmDeps = fetchPnpmDeps { inherit (finalAttrs) pname version src; inherit pnpm; fetcherVersion = 4; hash = "sha256-PB77S4CYjNJlRP84LhNhHGO5BSdIhRPF1aULMahAN/8="; }; nativeBuildInputs = [ pnpm nodejs pnpmConfigHook makeWrapper ]; # pnpmConfigHook already populates ./node_modules during configurePhase; # there's no build step since bot.ts is executed directly. dontBuild = true; installPhase = '' runHook preInstall # This node_modules also contains devDependencies (vite, svelte, etc.) # since they're not split from the frontend's in package.json. Harmless # but adds closure size; `pnpm prune --prod` here before copying would # trim it if that starts to matter. mkdir -p $out/lib/streamplace-bot cp -r src package.json node_modules $out/lib/streamplace-bot/ makeWrapper ${lib.getExe nodejs} $out/bin/streamplace-bot \ --add-flags "--experimental-strip-types" \ --add-flags "$out/lib/streamplace-bot/src/bot.ts" \ --chdir "$out/lib/streamplace-bot" runHook postInstall ''; meta = { description = "streamplace-bot: a streaming bot for Streamplace"; mainProgram = "streamplace-bot"; license = lib.licenses.mit; }; })