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