Merge pull request #306421 from mmarx/fix-vesktop

Patch RPATH for pre-built node modules in vesktop, terra-station, standardnotes, and logseq
This commit is contained in:
Pol Dellaiera 2024-04-29 22:49:20 +02:00 committed by GitHub
commit 64a883feec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 42 additions and 6 deletions

View File

@ -5,6 +5,7 @@
, bash
, makeWrapper
, electron
, asar
}:
let
@ -31,7 +32,7 @@ stdenv.mkDerivation rec {
inherit sha256;
};
nativeBuildInputs = [ makeWrapper ];
nativeBuildInputs = [ makeWrapper asar ];
dontConfigure = true;
dontBuild = true;
@ -48,6 +49,13 @@ stdenv.mkDerivation rec {
cp -a usr/share/* $out/share
cp -a "opt/Terra Station/"{locales,resources} $out/share/${pname}
# patch pre-built node modules
asar e $out/share/${pname}/resources/app.asar asar-unpacked
find asar-unpacked -name '*.node' -exec patchelf \
--add-rpath "${lib.makeLibraryPath [ stdenv.cc.cc.lib ]}" \
{} \;
asar p asar-unpacked $out/share/${pname}/resources/app.asar
substituteInPlace $out/share/applications/station-electron.desktop \
--replace "/opt/Terra Station/station-electron" ${pname}

View File

@ -4,6 +4,9 @@
, dpkg
, makeWrapper
, electron
, libsecret
, asar
, glib
, desktop-file-utils
, callPackage
}:
@ -28,16 +31,28 @@ stdenv.mkDerivation rec {
dontBuild = true;
nativeBuildInputs = [ makeWrapper dpkg desktop-file-utils ];
nativeBuildInputs = [ makeWrapper dpkg desktop-file-utils asar ];
unpackPhase = "dpkg-deb --fsys-tarfile $src | tar -x --no-same-permissions --no-same-owner";
installPhase = ''
installPhase = let
libPath = lib.makeLibraryPath [
libsecret
glib
stdenv.cc.cc.lib
];
in
''
runHook preInstall
mkdir -p $out/bin $out/share/standardnotes
cp -R usr/share/{applications,icons} $out/share
cp -R opt/Standard\ Notes/resources/app.asar $out/share/standardnotes/
asar e $out/share/standardnotes/app.asar asar-unpacked
find asar-unpacked -name '*.node' -exec patchelf \
--add-rpath "${libPath}" \
{} \;
asar p asar-unpacked $out/share/standardnotes/app.asar
makeWrapper ${electron}/bin/electron $out/bin/standardnotes \
--add-flags $out/share/standardnotes/app.asar

View File

@ -5,6 +5,7 @@
, makeWrapper
# graphs will not sync without matching upstream's major electron version
, electron_27
, autoPatchelfHook
, git
, nix-update-script
}:
@ -30,7 +31,8 @@ in {
dontConfigure = true;
dontBuild = true;
nativeBuildInputs = [ makeWrapper ];
nativeBuildInputs = [ makeWrapper autoPatchelfHook ];
buildInputs = [ stdenv.cc.cc.lib ];
installPhase = ''
runHook preInstall

View File

@ -13,6 +13,9 @@
, moreutils
, cacert
, nodePackages
, pipewire
, libpulseaudio
, autoPatchelfHook
, withTTS ? true
# Enables the use of vencord from nixpkgs instead of
# letting vesktop manage it's own version
@ -81,6 +84,13 @@ stdenv.mkDerivation (finalAttrs: {
nodePackages.pnpm
nodePackages.nodejs
makeWrapper
autoPatchelfHook
];
buildInputs = [
pipewire
libpulseaudio
stdenv.cc.cc.lib
];
patches = [
@ -106,6 +116,7 @@ stdenv.mkDerivation (finalAttrs: {
# using `pnpm exec` here apparently makes it ignore ELECTRON_SKIP_BINARY_DOWNLOAD
./node_modules/.bin/electron-builder \
--dir \
-c.asarUnpack="**/*.node" \
-c.electronDist=${electron}/libexec/electron \
-c.electronVersion=${electron.version}
'';
@ -115,8 +126,8 @@ stdenv.mkDerivation (finalAttrs: {
''
runHook preInstall
mkdir -p $out/opt/Vesktop/resources
cp dist/linux-*unpacked/resources/app.asar $out/opt/Vesktop/resources
mkdir -p $out/opt/Vesktop
cp -r dist/linux-*unpacked/resources $out/opt/Vesktop/
pushd build
${libicns}/bin/icns2png -x icon.icns