My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nomicon/pkgs/applications/networking/instant-messengers/signal-desktop/default.nix

153 lines
4.9 KiB

{ stdenv, lib, fetchurl, autoPatchelfHook, dpkg, wrapGAppsHook, makeWrapper, nixosTests
, gtk3, atk, at-spi2-atk, cairo, pango, gdk-pixbuf, glib, freetype, fontconfig
, dbus, libX11, xorg, libXi, libXcursor, libXdamage, libXrandr, libXcomposite
, libXext, libXfixes, libXrender, libXtst, libXScrnSaver, nss, nspr, alsa-lib
, cups, expat, libuuid, at-spi2-core, libappindicator-gtk3, mesa
# Runtime dependencies:
, systemd, libnotify, libdbusmenu, libpulseaudio, xdg-utils
# Unfortunately this also overwrites the UI language (not just the spell
# checking language!):
, hunspellDicts, spellcheckerLanguage ? null # E.g. "de_DE"
# For a full list of available languages:
# $ cat pkgs/development/libraries/hunspell/dictionaries.nix | grep "dictFileName =" | awk '{ print $3 }'
}:
let
customLanguageWrapperArgs = (with lib;
let
# E.g. "de_DE" -> "de-de" (spellcheckerLanguage -> hunspellDict)
spellLangComponents = splitString "_" spellcheckerLanguage;
hunspellDict = elemAt spellLangComponents 0 + "-" + toLower (elemAt spellLangComponents 1);
in lib.optionalString (spellcheckerLanguage != null) ''
--set HUNSPELL_DICTIONARIES "${hunspellDicts.${hunspellDict}}/share/hunspell" \
--set LC_MESSAGES "${spellcheckerLanguage}"'');
in stdenv.mkDerivation rec {
pname = "signal-desktop";
version = "5.42.0"; # 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 = "sha256-xjSj7eKaDV8WB0SiPb4orxKK8mV2a2EWiMBK7BE8mgU=";
};
nativeBuildInputs = [
autoPatchelfHook
dpkg
(wrapGAppsHook.override { makeBinaryWrapper = makeWrapper; })
];
buildInputs = [
alsa-lib
at-spi2-atk
at-spi2-core
atk
cairo
cups
dbus
expat
fontconfig
freetype
gdk-pixbuf
glib
gtk3
libX11
libXScrnSaver
libXcomposite
libXcursor
libXdamage
libXext
libXfixes
libXi
libXrandr
libXrender
libXtst
libappindicator-gtk3
libnotify
libuuid
mesa # for libgbm
nspr
nss
pango
systemd
xorg.libxcb
xorg.libxshmfence
];
runtimeDependencies = [
(lib.getLib systemd)
libnotify
libdbusmenu
xdg-utils
];
unpackPhase = "dpkg-deb -x $src .";
dontBuild = true;
dontConfigure = true;
dontPatchELF = true;
# We need to run autoPatchelf manually with the "no-recurse" option, see
# https://github.com/NixOS/nixpkgs/pull/78413 for the reasons.
dontAutoPatchelf = true;
installPhase = ''
runHook preInstall
mkdir -p $out/lib
mv usr/share $out/share
mv opt/Signal $out/lib/Signal
# Note: The following path contains bundled libraries:
# $out/lib/Signal/resources/app.asar.unpacked/node_modules/sharp/vendor/lib/
# We run autoPatchelf with the "no-recurse" option to avoid picking those
# up, but resources/app.asar still requires them.
# Symlink to bin
mkdir -p $out/bin
ln -s $out/lib/Signal/signal-desktop $out/bin/signal-desktop
# Create required symlinks:
ln -s libGLESv2.so $out/lib/Signal/libGLESv2.so.2
runHook postInstall
'';
preFixup = ''
gappsWrapperArgs+=(
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ stdenv.cc.cc ] }"
${customLanguageWrapperArgs}
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--enable-features=UseOzonePlatform --ozone-platform=wayland}}"
--suffix PATH : ${lib.makeBinPath [ xdg-utils ]}
)
# Fix the desktop link
substituteInPlace $out/share/applications/signal-desktop.desktop \
--replace /opt/Signal/signal-desktop $out/bin/signal-desktop
autoPatchelf --no-recurse -- $out/lib/Signal/
patchelf --add-needed ${libpulseaudio}/lib/libpulse.so $out/lib/Signal/resources/app.asar.unpacked/node_modules/ringrtc/build/linux/libringrtc-x64.node
'';
# Tests if the application launches and waits for "Link your phone to Signal Desktop":
passthru.tests.application-launch = nixosTests.signal-desktop;
meta = {
description = "Private, simple, and secure messenger";
longDescription = ''
Signal Desktop is an Electron application that links with your
"Signal Android" or "Signal iOS" app.
'';
homepage = "https://signal.org/";
changelog = "https://github.com/signalapp/Signal-Desktop/releases/tag/v${version}";
license = lib.licenses.agpl3Only;
maintainers = with lib.maintainers; [ mic92 equirosa ];
platforms = [ "x86_64-linux" ];
};
}