nixos_flake_config/packages/viber/default.nix

172 lines
3.5 KiB
Nix
Raw Normal View History

2023-10-29 12:15:51 +01:00
{
alsa-lib,
brotli,
cups,
curl,
bubblewrap,
bash,
writeShellScriptBin,
2023-10-29 12:15:51 +01:00
dbus,
dpkg,
expat,
fetchurl,
fontconfig,
freetype,
glib,
gst_all_1,
harfbuzz,
krb5,
lcms,
lib,
libcap,
libevent,
libGL,
libGLU,
libopus,
libpulseaudio,
libwebp,
libxkbcommon,
libxml2,
libxslt,
makeWrapper,
mesa,
nspr,
nss,
openssl,
snappy,
stdenv,
systemd,
wayland,
xorg,
zlib,
zstd,
...
}:
stdenv.mkDerivation {
pname = "viber";
2024-07-31 12:15:06 +02:00
version = "23.2.0.3";
2023-10-29 12:15:51 +01:00
src = fetchurl {
# Official link: https://download.cdn.viber.com/cdn/desktop/Linux/viber.deb
url = "https://download.cdn.viber.com/cdn/desktop/Linux/viber.deb";
2024-07-31 12:14:17 +02:00
hash = "sha256-9WHiI2WlsgEhCPkrQoAunmF6lSb2n5RgQJ2+sdnSShM=";
2023-10-29 12:15:51 +01:00
};
2025-01-10 18:11:42 +01:00
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ dpkg ];
2023-10-29 12:15:51 +01:00
dontUnpack = true;
libPath = lib.makeLibraryPath [
alsa-lib
brotli
cups
curl
dbus
expat
fontconfig
freetype
glib
gst_all_1.gst-plugins-bad
gst_all_1.gst-plugins-base
gst_all_1.gstreamer
harfbuzz
krb5
lcms
libcap
libevent
libGLU
libGL
libopus
libpulseaudio
libwebp
libxkbcommon
libxml2
libxslt
mesa
nspr
nss
openssl
snappy
stdenv.cc.cc
systemd
wayland
zlib
zstd
xorg.libICE
xorg.libSM
xorg.libX11
xorg.libxcb
xorg.libXcomposite
xorg.libXcursor
xorg.libXdamage
xorg.libXext
xorg.libXfixes
xorg.libXi
xorg.libXrandr
xorg.libXrender
xorg.libXScrnSaver
xorg.libXtst
xorg.xcbutilimage
xorg.xcbutilkeysyms
xorg.xcbutilrenderutil
xorg.xcbutilwm
xorg.libxkbfile
];
2025-01-10 18:11:42 +01:00
installPhase =
let
viberWrap = writeShellScriptBin "viberWrap" ''
${bubblewrap}/bin/bwrap --bind / / \
--dev /dev \
--tmpfs $HOME \
--bind $HOME/.ViberPC/ $HOME/.ViberPC \
--bind $HOME/Downloads/ $HOME/Downloads \
$@
'';
in
''
dpkg-deb -x $src $out
mkdir -p $out/bin
2023-10-29 12:15:51 +01:00
2025-01-10 18:11:42 +01:00
# Soothe nix-build "suspicions"
chmod -R g-w $out
2023-10-29 12:15:51 +01:00
2025-01-10 18:11:42 +01:00
for file in $(find $out -type f \( -perm /0111 -o -name \*.so\* \) ); do
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true
patchelf --set-rpath $libPath:$out/opt/viber/lib $file || true
done
2023-10-29 12:15:51 +01:00
2025-01-10 18:11:42 +01:00
# qt.conf is not working, so override everything using environment variables
wrapProgram $out/opt/viber/Viber \
--set QT_PLUGIN_PATH "$out/opt/viber/plugins" \
--set QT_XKB_CONFIG_ROOT "${xorg.xkeyboardconfig}/share/X11/xkb" \
--set QTCOMPOSE "${xorg.libX11.out}/share/X11/locale" \
--set QML2_IMPORT_PATH "$out/opt/viber/qml"
2025-01-10 18:11:42 +01:00
echo "#!${bash}/bin/bash" > $out/bin/viber
echo "${viberWrap}/bin/viberWrap $out/opt/viber/Viber" >> $out/bin/viber
chmod +x $out/bin/viber
2023-10-29 12:15:51 +01:00
2025-01-10 18:11:42 +01:00
mv $out/usr/share $out/share
rm -rf $out/usr
2023-10-29 12:15:51 +01:00
2025-01-10 18:11:42 +01:00
# Fix the desktop link
substituteInPlace $out/share/applications/viber.desktop \
--replace /opt/viber/Viber $out/opt/viber/Viber \
--replace /usr/share/ $out/share/
'';
2023-10-29 12:15:51 +01:00
dontStrip = true;
dontPatchELF = true;
meta = {
homepage = "https://www.viber.com";
description = "An instant messaging and Voice over IP (VoIP) app";
2025-01-10 18:11:42 +01:00
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
2023-10-29 12:15:51 +01:00
license = lib.licenses.unfree;
2025-01-10 18:11:42 +01:00
platforms = [ "x86_64-linux" ];
maintainers = with lib.maintainers; [ jagajaga ];
2023-10-29 12:15:51 +01:00
};
}