signal-desktop: use autoPatchelfHook, wrap properly (#77850)

Most prominently we don't use `phases` because of https://github.com/NixOS/nixpkgs/issues/28910.
This is also problematic when using wrapGAppsHook.
In order to use wrapGAppsHook's automatic wrapping
(this was done manually before because there was no fixupPhase)
we need to install signal at lib/Signal instead of just into libexec.
That's because it would try to wrap .so files.
This commit is contained in:
worldofpeace 2020-01-17 16:51:06 -05:00 committed by Michael Weiss
parent 63f515a3df
commit 15e0b23f48

View file

@ -2,7 +2,8 @@
, gnome2, gtk3, atk, at-spi2-atk, cairo, pango, gdk-pixbuf, glib, freetype, fontconfig , gnome2, gtk3, atk, at-spi2-atk, cairo, pango, gdk-pixbuf, glib, freetype, fontconfig
, dbus, libX11, xorg, libXi, libXcursor, libXdamage, libXrandr, libXcomposite , dbus, libX11, xorg, libXi, libXcursor, libXdamage, libXrandr, libXcomposite
, libXext, libXfixes, libXrender, libXtst, libXScrnSaver, nss, nspr, alsaLib , libXext, libXfixes, libXrender, libXtst, libXScrnSaver, nss, nspr, alsaLib
, cups, expat, udev, libnotify, libuuid, at-spi2-core, libappindicator-gtk3 , cups, expat, systemd, libnotify, libuuid, at-spi2-core, libappindicator-gtk3
, autoPatchelfHook
# Unfortunately this also overwrites the UI language (not just the spell # Unfortunately this also overwrites the UI language (not just the spell
# checking language!): # checking language!):
, hunspellDicts, spellcheckerLanguage ? null # E.g. "de_DE" , hunspellDicts, spellcheckerLanguage ? null # E.g. "de_DE"
@ -21,11 +22,32 @@ let
--set HUNSPELL_DICTIONARIES "${hunspellDicts.${hunspellDict}}/share/hunspell" \ --set HUNSPELL_DICTIONARIES "${hunspellDicts.${hunspellDict}}/share/hunspell" \
--set LC_MESSAGES "${spellcheckerLanguage}"'' --set LC_MESSAGES "${spellcheckerLanguage}"''
else ""); else "");
rpath = lib.makeLibraryPath [ in stdenv.mkDerivation rec {
pname = "signal-desktop";
version = "1.29.6"; # Please backport all updates to the stable channel.
# All releases have a limited lifetime and "expire" 90 days after the release.
# When releases "expire" the application becomes unusable until an update is
# applied. The expiration date for the current release can be extracted with:
# $ grep -a "^{\"buildExpiration" "${signal-desktop}/lib/Signal/resources/app.asar"
# (Alternatively we could try to patch the asar archive, but that requires a
# few additional steps and might not be the best idea.)
src = fetchurl {
url = "https://updates.signal.org/desktop/apt/pool/main/s/signal-desktop/signal-desktop_${version}_amd64.deb";
sha256 = "1s1rc4kyv0nxz5fy5ia7fflphf3izk80ks71q4wd67k1g9lvcw24";
};
nativeBuildInputs = [
autoPatchelfHook
dpkg
wrapGAppsHook
];
buildInputs = [
alsaLib alsaLib
atk
at-spi2-atk at-spi2-atk
at-spi2-core at-spi2-core
atk
cairo cairo
cups cups
dbus dbus
@ -36,10 +58,6 @@ let
glib glib
gnome2.GConf gnome2.GConf
gtk3 gtk3
pango
libappindicator-gtk3
libnotify
libuuid
libX11 libX11
libXScrnSaver libXScrnSaver
libXcomposite libXcomposite
@ -51,55 +69,42 @@ let
libXrandr libXrandr
libXrender libXrender
libXtst libXtst
libappindicator-gtk3
libnotify
libuuid
nspr nspr
nss nss
udev pango
systemd
xorg.libxcb xorg.libxcb
]; ];
in stdenv.mkDerivation rec { runtimeDependencies = [
pname = "signal-desktop"; systemd.lib
version = "1.29.6"; # Please backport all updates to the stable channel. ];
# All releases have a limited lifetime and "expire" 90 days after the release.
# When releases "expire" the application becomes unusable until an update is
# applied. The expiration date for the current release can be extracted with:
# $ grep -a "^{\"buildExpiration" "${signal-desktop}/libexec/resources/app.asar"
# (Alternatively we could try to patch the asar archive, but that requires a
# few additional steps and might not be the best idea.)
src = fetchurl {
url = "https://updates.signal.org/desktop/apt/pool/main/s/signal-desktop/signal-desktop_${version}_amd64.deb";
sha256 = "1s1rc4kyv0nxz5fy5ia7fflphf3izk80ks71q4wd67k1g9lvcw24";
};
phases = [ "unpackPhase" "installPhase" ];
nativeBuildInputs = [ dpkg wrapGAppsHook ];
unpackPhase = "dpkg-deb -x $src ."; unpackPhase = "dpkg-deb -x $src .";
dontBuild = true;
dontConfigure = true;
dontPatchELF = true;
installPhase = '' installPhase = ''
mkdir -p $out mkdir -p $out/lib
cp -R opt $out
mv ./usr/share $out/share mv usr/share $out/share
mv $out/opt/Signal $out/libexec mv opt/Signal $out/lib
rmdir $out/opt
chmod -R g-w $out
# Patch signal
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath ${rpath}:$out/libexec $out/libexec/signal-desktop
wrapProgram $out/libexec/signal-desktop \
--prefix XDG_DATA_DIRS : "${gtk3}/share/gsettings-schemas/${gtk3.name}/" \
--prefix LD_LIBRARY_PATH : "${stdenv.cc.cc.lib}/lib" \
${customLanguageWrapperArgs} \
"''${gappsWrapperArgs[@]}"
# Symlink to bin # Symlink to bin
mkdir -p $out/bin mkdir -p $out/bin
ln -s $out/libexec/signal-desktop $out/bin/signal-desktop ln -s $out/lib/Signal/signal-desktop $out/bin/signal-desktop
'';
preFixup = ''
gappsWrapperArgs+=(
--prefix LD_LIBRARY_PATH : "${stdenv.lib.makeLibraryPath [ stdenv.cc.cc ] }"
${customLanguageWrapperArgs}
)
# Fix the desktop link # Fix the desktop link
substituteInPlace $out/share/applications/signal-desktop.desktop \ substituteInPlace $out/share/applications/signal-desktop.desktop \