From f0874d863450d9b1d393c055ec53d49b93a7bc67 Mon Sep 17 00:00:00 2001 From: asepharyana Date: Sun, 30 Aug 2026 11:12:01 +0700 Subject: [PATCH] build(discord-gateway): drop cmake/rust toolchain + prune dead @types & opusscript from bundle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - nativeBuildInputs: remove cmake, rustc, cargo, git — GMW's only native deps (@discordjs/opus, sharp) are PREBUILT, no source compile needed (cmake/rust were inherited for node-datachannel which is 9router, not GMW). python3/gnumake/gcc stay as node-gyp fallback for opus. - pruneProd: also strip .pnpm/@types+* (pure TS decls pulled into the prod graph as real deps by discord-api-types/pg-protocol, never required at runtime) and .pnpm/opusscript@* (pure-JS fallback Opus engine that prism-media only loads IF native @discordjs/opus fails — native is always present, so opusscript is never executed). - Verified: nix flake check OK; typecheck + biome check src/ green; runtime smoke test post-prune loads @discordjs/voice, sharp, selfbot, tiktoken, piscina and encodes a frame via native opus. --- flake.nix | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 5000a9fc..419d635b 100644 --- a/flake.nix +++ b/flake.nix @@ -82,6 +82,17 @@ [ "$d" = "node_modules" ] && continue; \ grep -qF ".pnpm/$d" $TMPDIR/prod-pnms.txt || rm -rf "$d"; \ done ) || true + # Drop runtime-dead packages that still land in the prod graph: + # - `@types/*` (pure TypeScript declarations) get pulled in as + # REAL dependencies by type-aware deps (discord-api-types -> + # @types/node, pg-protocol -> @types/pg, ...) even though nothing + # ever `require`s them at runtime. Safe to strip. + # - `opusscript` is only a pure-JS fallback Opus engine that + # prism-media's loader uses IF `@discordjs/opus` (native, always + # present/prebuilt) fails to load. Since the native engine loads, + # opusscript is never executed — dead weight pulled in via + # discord.js-selfbot-v13's dependency. Strip it too. + ( cd node_modules/.pnpm && rm -rf @types+* opusscript@* 2>/dev/null ) || true # Drop symlinks whose .pnpm target was pruned (top-level, scoped dirs, # hoist, .bin — any depth). Mirrors stdenv's noBrokenSymlinks check, # which would otherwise fail the fixupPhase. @@ -132,14 +143,17 @@ WRAPPER src = ./services/discord-gateway; + # cmake + rust/cargo were inherited for node-datachannel-style native + # deps — that's 9router/omniroute, NOT GMW. GMW's only native deps + # are @discordjs/opus + sharp, both PREBUILT (node-pre-gyp / @img + # libvips download), so no cmake or rust toolchain is needed. + # python3/gnumake/gcc stay as node-gyp fallback for @discordjs/opus. nativeBuildInputs = [ nodejs pnpm - pkgs.python3 pkgs.gnumake pkgs.gcc pkgs.cmake - pkgs.rustc pkgs.cargo + pkgs.python3 pkgs.gnumake pkgs.gcc pkgs.pkg-config pkgs.openssl pkgs.openssl.dev - pkgs.git # for any FetchContent-based deps during native builds pkgs.cacert ];