Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8473b0610 | ||
|
|
3deca91ffe | ||
|
|
edec2edf82 | ||
|
|
17013fe1e5 |
@@ -11,15 +11,10 @@
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
|
||||
# libdatachannel 0.24.0 — the version the GoLive N-API binding links
|
||||
# against. nixpkgs 0.24.1 was built against a newer glibc (ABI
|
||||
# GLIBC_ABI_GNU2_TLS missing on this host), so pin 0.24.0 explicitly.
|
||||
libdatachannel-src = pkgs.fetchFromGitHub {
|
||||
owner = "paullouisageneau";
|
||||
repo = "libdatachannel";
|
||||
rev = "v0.24.0";
|
||||
sha256 = "1jk53qsrihg1bsc0dmr5rajkgp3hi7d98pvpr0qnpk15b7ilb6fy";
|
||||
};
|
||||
# libdatachannel for the GoLive N-API binding. nixpkgs 0.24.1 is built
|
||||
# against this host's glibc and ships both lib + dev headers, so the
|
||||
# binding links cleanly inside the Nix sandbox (no manual cmake build).
|
||||
libdatachannel = pkgs.libdatachannel;
|
||||
|
||||
# Source filter: `path:` literals do NOT respect .gitignore by default,
|
||||
# so a dirty local out/ (stale chunks from previous builds) leaks into
|
||||
@@ -172,6 +167,7 @@ WRAPPER
|
||||
pkgs.pkg-config
|
||||
pkgs.openssl
|
||||
pkgs.openssl.dev
|
||||
libdatachannel.dev # rtc/rtc.hpp headers for the GoLive binding
|
||||
pkgs.git # libdatachannel FetchContent clones from GitHub
|
||||
pkgs.cacert
|
||||
];
|
||||
@@ -201,24 +197,21 @@ WRAPPER
|
||||
done
|
||||
echo "=== Building libdatachannel-min N-API binding ==="
|
||||
# The GoLive screen-share stack uses a minimal N-API binding
|
||||
# (native/libdatachannel-min) over libdatachannel 0.24.0 built from
|
||||
# source. node-gyp links against the libdatachannel .so.
|
||||
# (native/libdatachannel-min) over nixpkgs libdatachannel.
|
||||
(
|
||||
cd native/libdatachannel-min
|
||||
# libdatachannel 0.24.0 fetched from GitHub (see flake inputs) —
|
||||
# build with CMake, then node-gyp links against the .so.
|
||||
mkdir -p build/ldc
|
||||
cd build/ldc
|
||||
cmake -DCMAKE_BUILD_TYPE=Release \
|
||||
-DNO_EXAMPLES=ON -DNO_TESTS=ON -DNO_WEBSOCKET=ON \
|
||||
-DNO_MEDIA=OFF \
|
||||
-DCMAKE_INSTALL_PREFIX=$PWD/install \
|
||||
"${opensslDevEnv}" ${libdatachannel-src} 2>&1 || true
|
||||
make -j"$NIX_BUILD_CORES" 2>&1 || true
|
||||
cd ..
|
||||
LD_LIBRARY_PATH=$PWD/ldc node-gyp rebuild 2>&1 || true
|
||||
cp -r build/Release/datachannel_min.node . 2>/dev/null || true
|
||||
echo "libdatachannel-min binding: $(ls -la datachannel_min.node 2>/dev/null | awk '{print $5}') bytes"
|
||||
# binding.gyp resolves include/lib from env (LDC_INCLUDE = .dev
|
||||
# include root, LDC_LIB = lib output dir, NAPI_INCLUDE =
|
||||
# node-addon-api include root).
|
||||
NAPI_INCLUDE=$(find ../../node_modules/.pnpm -maxdepth 3 \
|
||||
-type d -path "*node_modules/node-addon-api" | head -1)
|
||||
echo "NAPI_INCLUDE=$NAPI_INCLUDE"
|
||||
LDC_INCLUDE=${libdatachannel.dev} LDC_LIB=${libdatachannel.out}/lib/libdatachannel.so.0.24.1 \
|
||||
NAPI_INCLUDE=$NAPI_INCLUDE \
|
||||
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 ===="
|
||||
npx tsc 2>&1
|
||||
@@ -254,6 +247,22 @@ WRAPPER
|
||||
mkdir -p $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
|
||||
cp -r drizzle $out/lib/gmw-discord-gateway/ 2>/dev/null || true
|
||||
|
||||
@@ -262,6 +271,7 @@ WRAPPER
|
||||
#!${pkgs.runtimeShell}
|
||||
cd $out/lib/gmw-discord-gateway
|
||||
export PATH=${pkgs.ffmpeg-headless}/bin:${pkgs.yt-dlp}/bin:\$PATH
|
||||
export LD_LIBRARY_PATH=${libdatachannel.out}/lib:\$LD_LIBRARY_PATH
|
||||
exec ${nodejs}/bin/node dist/index.js
|
||||
WRAPPER
|
||||
chmod +x $out/bin/gmw-discord-gateway
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
"target_name": "libdatachannel_min",
|
||||
"sources": ["binding.cpp"],
|
||||
"include_dirs": [
|
||||
"<!@(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 \"console.log(process.env.NAPI_INCLUDE || (() => { try { return require('node-addon-api').include; } catch { return '/nonexistent'; } })())\")",
|
||||
"<!(node -e \"const s=process.env.LDC_INCLUDE||'/nix/store/39a85gpfjqy3h3k8jwrwh7m9yc3inqw7-source';console.log(s+'/include')\")"
|
||||
],
|
||||
"libraries": [
|
||||
"/tmp/ldc-build/libdatachannel.so.0.24.0"
|
||||
"<!(node -e \"console.log(process.env.LDC_LIB || '/tmp/ldc-build/libdatachannel.so.0.24.0')\")"
|
||||
],
|
||||
"cflags": ["-std=c++17", "-fexceptions"],
|
||||
"cflags_cc": ["-std=c++17", "-fexceptions"],
|
||||
|
||||
Reference in New Issue
Block a user