build(nix): gateway binding — gyp env-var paths, correct cwd, tolerant install
- binding.gyp: resolve libdatachannel include/.so via LDC_INCLUDE/LDC_LIB env (node -e expression) instead of hardcoded /tmp/ldc-build paths - flake buildPhase: run node-gyp from native/libdatachannel-min root (was build/ subdir → 'binding.gyp not found'); export LDC_INCLUDE (fetchFromGitHub source) + LDC_LIB (cmake build dir) - flake installPhase: tolerate missing binding (screen share disabled, gateway still starts); copy .so real files via -rL
This commit is contained in:
@@ -209,16 +209,21 @@ WRAPPER
|
|||||||
# build with CMake, then node-gyp links against the .so.
|
# build with CMake, then node-gyp links against the .so.
|
||||||
mkdir -p build/ldc
|
mkdir -p build/ldc
|
||||||
cd build/ldc
|
cd build/ldc
|
||||||
cmake -DCMAKE_BUILD_TYPE=Release \
|
OPENSSL_ROOT_DIR="${opensslDevEnv}" cmake -DCMAKE_BUILD_TYPE=Release \
|
||||||
-DNO_EXAMPLES=ON -DNO_TESTS=ON -DNO_WEBSOCKET=ON \
|
-DNO_EXAMPLES=ON -DNO_TESTS=ON -DNO_WEBSOCKET=ON \
|
||||||
-DNO_MEDIA=OFF \
|
-DNO_MEDIA=OFF \
|
||||||
-DCMAKE_INSTALL_PREFIX=$PWD/install \
|
-DCMAKE_INSTALL_PREFIX=$PWD/install \
|
||||||
"${opensslDevEnv}" ${libdatachannel-src} 2>&1 || true
|
${libdatachannel-src} 2>&1 || true
|
||||||
make -j"$NIX_BUILD_CORES" 2>&1 || true
|
make -j"$NIX_BUILD_CORES" 2>&1 || true
|
||||||
cd ..
|
LDC_DIR=$PWD
|
||||||
LD_LIBRARY_PATH=$PWD/ldc node-gyp rebuild 2>&1 || true
|
cd ../..
|
||||||
cp -r build/Release/datachannel_min.node . 2>/dev/null || true
|
# binding.gyp resolves include/lib from env (LDC_INCLUDE = source
|
||||||
echo "libdatachannel-min binding: $(ls -la datachannel_min.node 2>/dev/null | awk '{print $5}') bytes"
|
# dir with rtc/rtc.hpp, LDC_LIB = cmake build dir with the .so).
|
||||||
|
LDC_INCLUDE=${libdatachannel-src} LDC_LIB=$LDC_DIR \
|
||||||
|
npx node-gyp rebuild 2>&1 || true
|
||||||
|
ls -la build/Release/datachannel_min.node 2>/dev/null \
|
||||||
|
&& echo "libdatachannel-min binding OK: $(stat -c%s build/Release/datachannel_min.node) bytes" \
|
||||||
|
|| echo "WARN: libdatachannel-min binding build FAILED (screen share disabled)"
|
||||||
)
|
)
|
||||||
echo "=== Compiling TypeScript ===="
|
echo "=== Compiling TypeScript ===="
|
||||||
npx tsc 2>&1
|
npx tsc 2>&1
|
||||||
@@ -254,6 +259,22 @@ WRAPPER
|
|||||||
mkdir -p $out/lib/gmw-discord-gateway
|
mkdir -p $out/lib/gmw-discord-gateway
|
||||||
cp -r dist node_modules package.json tsconfig.json $out/lib/gmw-discord-gateway/
|
cp -r dist node_modules package.json tsconfig.json $out/lib/gmw-discord-gateway/
|
||||||
|
|
||||||
|
# GoLive native binding — loadNative resolves it relative to
|
||||||
|
# dist/goLive/native.js, i.e. <root>/native/libdatachannel-min/
|
||||||
|
# build/Release/datachannel_min.node; libdatachannel .so must sit
|
||||||
|
# next to it and be on LD_LIBRARY_PATH at runtime.
|
||||||
|
mkdir -p $out/lib/gmw-discord-gateway/native/libdatachannel-min/build/Release
|
||||||
|
cp native/libdatachannel-min/build/Release/datachannel_min.node \
|
||||||
|
$out/lib/gmw-discord-gateway/native/libdatachannel-min/build/Release/ 2>/dev/null || true
|
||||||
|
mkdir -p $out/lib/gmw-discord-gateway/native/libdatachannel-min/build/ldc
|
||||||
|
cp -rL native/libdatachannel-min/build/ldc/libdatachannel.so* \
|
||||||
|
$out/lib/gmw-discord-gateway/native/libdatachannel-min/build/ldc/ 2>/dev/null || true
|
||||||
|
# If the binding failed to build, screen share is simply disabled —
|
||||||
|
# the gateway itself must still start.
|
||||||
|
if [ ! -f $out/lib/gmw-discord-gateway/native/libdatachannel-min/build/Release/datachannel_min.node ]; then
|
||||||
|
echo "WARN: datachannel_min.node missing — GoLive screen share disabled in this build"
|
||||||
|
fi
|
||||||
|
|
||||||
# Also include drizzle migrations if they exist
|
# Also include drizzle migrations if they exist
|
||||||
cp -r drizzle $out/lib/gmw-discord-gateway/ 2>/dev/null || true
|
cp -r drizzle $out/lib/gmw-discord-gateway/ 2>/dev/null || true
|
||||||
|
|
||||||
@@ -262,6 +283,7 @@ WRAPPER
|
|||||||
#!${pkgs.runtimeShell}
|
#!${pkgs.runtimeShell}
|
||||||
cd $out/lib/gmw-discord-gateway
|
cd $out/lib/gmw-discord-gateway
|
||||||
export PATH=${pkgs.ffmpeg-headless}/bin:${pkgs.yt-dlp}/bin:\$PATH
|
export PATH=${pkgs.ffmpeg-headless}/bin:${pkgs.yt-dlp}/bin:\$PATH
|
||||||
|
export LD_LIBRARY_PATH=$out/lib/gmw-discord-gateway/native/libdatachannel-min/build/ldc:\$LD_LIBRARY_PATH
|
||||||
exec ${nodejs}/bin/node dist/index.js
|
exec ${nodejs}/bin/node dist/index.js
|
||||||
WRAPPER
|
WRAPPER
|
||||||
chmod +x $out/bin/gmw-discord-gateway
|
chmod +x $out/bin/gmw-discord-gateway
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
"sources": ["binding.cpp"],
|
"sources": ["binding.cpp"],
|
||||||
"include_dirs": [
|
"include_dirs": [
|
||||||
"<!@(node -p \"require('node-addon-api').include\")",
|
"<!@(node -p \"require('node-addon-api').include\")",
|
||||||
"/home/code/GMW/services/discord-gateway/node_modules/.pnpm/@lng2004+node-datachannel@0.32.0-20260202/node_modules/@lng2004/node-datachannel/build/_deps/libdatachannel-src/include"
|
"<!(node -e \"const s=process.env.LDC_INCLUDE||'/nix/store/39a85gpfjqy3h3k8jwrwh7m9yc3inqw7-source';console.log(s+'/include')\")"
|
||||||
],
|
],
|
||||||
"libraries": [
|
"libraries": [
|
||||||
"/tmp/ldc-build/libdatachannel.so.0.24.0"
|
"<!(node -e \"const s=process.env.LDC_LIB||'/tmp/ldc-build';console.log(s+'/libdatachannel.so.0.24.0')\")"
|
||||||
],
|
],
|
||||||
"cflags": ["-std=c++17", "-fexceptions"],
|
"cflags": ["-std=c++17", "-fexceptions"],
|
||||||
"cflags_cc": ["-std=c++17", "-fexceptions"],
|
"cflags_cc": ["-std=c++17", "-fexceptions"],
|
||||||
|
|||||||
Reference in New Issue
Block a user