Amp-Thread-ID: https://ampcode.com/threads/T-a6cf4bd2-36d0-4ef8-ada6-a8e2850fcacf Co-authored-by: Amp <amp@ampcode.com>
44 lines
1.1 KiB
Bash
44 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
# Script to patch Electron for NixOS
|
|
|
|
set -e
|
|
|
|
if [ ! -d "node_modules/electron/dist" ]; then
|
|
echo "Electron not installed yet. Run 'npm install' first."
|
|
exit 1
|
|
fi
|
|
|
|
echo "Patching Electron binaries for NixOS..."
|
|
|
|
cd node_modules/electron/dist
|
|
|
|
# Patch main electron binary
|
|
if [ -f electron ]; then
|
|
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" electron
|
|
patchelf --set-rpath "${LD_LIBRARY_PATH}" electron
|
|
echo "✓ Patched electron"
|
|
fi
|
|
|
|
# Patch chrome-sandbox
|
|
if [ -f chrome-sandbox ]; then
|
|
chmod u+w chrome-sandbox
|
|
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" chrome-sandbox || true
|
|
patchelf --set-rpath "${LD_LIBRARY_PATH}" chrome-sandbox || true
|
|
echo "✓ Patched chrome-sandbox"
|
|
fi
|
|
|
|
# Copy libffmpeg from the system
|
|
if [ ! -f libffmpeg.so ]; then
|
|
# Try to find libffmpeg in the system
|
|
for ffmpeg_lib in /nix/store/*-electron-*/lib/libffmpeg.so; do
|
|
if [ -f "$ffmpeg_lib" ]; then
|
|
cp "$ffmpeg_lib" .
|
|
chmod +w libffmpeg.so
|
|
echo "✓ Copied libffmpeg.so"
|
|
break
|
|
fi
|
|
done
|
|
fi
|
|
|
|
echo "Electron patching complete!"
|