From a03b2b99af92a97198c903436823d3135a5f6e49 Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Mon, 22 Jan 2018 22:17:09 +0100 Subject: [PATCH] tdesktop: Fix the execution in a pure environment Telegram was crashing when executed within a pure environment (nix-shell -p tdesktop --pure). Setting the environment variables QT_PLUGIN_PATH and XDG_RUNTIME_DIR should resolve this issue. Fix #33729. --- .../instant-messengers/telegram/tdesktop/default.nix | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/networking/instant-messengers/telegram/tdesktop/default.nix b/pkgs/applications/networking/instant-messengers/telegram/tdesktop/default.nix index 82302ad5db39..c4158d280e2b 100644 --- a/pkgs/applications/networking/instant-messengers/telegram/tdesktop/default.nix +++ b/pkgs/applications/networking/instant-messengers/telegram/tdesktop/default.nix @@ -1,5 +1,5 @@ { mkDerivation, lib, fetchgit, fetchpatch -, pkgconfig, gyp, cmake, gcc7 +, pkgconfig, gyp, cmake, gcc7, makeWrapper , qtbase, qtimageformats, gtk3, libappindicator-gtk3 , dee, ffmpeg, openalSoft, minizip, libopus, alsaLib, libpulseaudio, range-v3 }: @@ -31,7 +31,7 @@ mkDerivation rec { }) ]; - nativeBuildInputs = [ pkgconfig gyp cmake gcc7 ]; + nativeBuildInputs = [ pkgconfig gyp cmake gcc7 makeWrapper ]; buildInputs = [ qtbase qtimageformats gtk3 libappindicator-gtk3 @@ -107,6 +107,13 @@ mkDerivation rec { for icon_size in 16 32 48 64 128 256 512; do install -Dm644 "../../../Telegram/Resources/art/icon''${icon_size}.png" "$out/share/icons/hicolor/''${icon_size}x''${icon_size}/apps/telegram-desktop.png" done + + # This is necessary to run Telegram in a pure environment. + wrapProgram $out/bin/telegram-desktop \ + --prefix QT_PLUGIN_PATH : "${qtbase}/${qtbase.qtPluginPrefix}" \ + --set XDG_RUNTIME_DIR "XDG-RUNTIME-DIR" + sed -i $out/bin/telegram-desktop \ + -e "s,'XDG-RUNTIME-DIR',\"\''${XDG_RUNTIME_DIR:-/run/user/\$(id --user)}\"," ''; meta = with lib; {