nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 fetchurl,
3 lib,
4 stdenv,
5 dpkg,
6 makeWrapper,
7 alsa-lib,
8 brotli,
9 cups,
10 curl,
11 dbus,
12 expat,
13 fontconfig,
14 freetype,
15 glib,
16 gst_all_1,
17 harfbuzz,
18 lcms,
19 libcap,
20 libevent,
21 libGL,
22 libGLU,
23 libkrb5,
24 libopus,
25 libpulseaudio,
26 libxkbcommon,
27 libxkbfile,
28 libxml2,
29 libxslt,
30 libwebp,
31 libgbm,
32 nspr,
33 nss,
34 openssl,
35 snappy,
36 systemd,
37 wayland,
38 xorg,
39 zlib,
40 zstd,
41 ...
42}:
43
44stdenv.mkDerivation {
45 pname = "viber";
46 version = "23.2.0.3";
47
48 src = fetchurl {
49 # Taking Internet Archive snapshot of a specific version to avoid breakage
50 # on new versions
51 url = "https://web.archive.org/web/20240824071651/https://download.cdn.viber.com/cdn/desktop/Linux/viber.deb";
52 hash = "sha256-9WHiI2WlsgEhCPkrQoAunmF6lSb2n5RgQJ2+sdnSShM=";
53 };
54
55 nativeBuildInputs = [ makeWrapper ];
56
57 buildInputs = [ dpkg ];
58
59 dontUnpack = true;
60
61 libPath = lib.makeLibraryPath [
62 alsa-lib
63 brotli
64 cups
65 curl
66 dbus
67 expat
68 fontconfig
69 freetype
70 glib
71 gst_all_1.gst-plugins-base
72 gst_all_1.gstreamer
73 harfbuzz
74 lcms
75 libcap
76 libevent
77 libGLU
78 libGL
79 libkrb5
80 libopus
81 libpulseaudio
82 libxkbcommon
83 libxkbfile
84 libxml2
85 libxslt
86 libwebp
87 libgbm
88 nspr
89 nss
90 openssl
91 snappy
92 stdenv.cc.cc
93 systemd
94 wayland
95 zlib
96 zstd
97
98 xorg.libICE
99 xorg.libSM
100 xorg.libX11
101 xorg.libxcb
102 xorg.libXcomposite
103 xorg.libXcursor
104 xorg.libXdamage
105 xorg.libXext
106 xorg.libXfixes
107 xorg.libXi
108 xorg.libXrandr
109 xorg.libXrender
110 xorg.libXScrnSaver
111 xorg.libXtst
112 xorg.xcbutilimage
113 xorg.xcbutilkeysyms
114 xorg.xcbutilrenderutil
115 xorg.xcbutilwm
116 ];
117
118 installPhase = ''
119 dpkg-deb -x $src $out
120 mkdir -p $out/bin
121
122 # Soothe nix-build "suspicions"
123 chmod -R g-w $out
124
125 for file in $(find $out -type f \( -perm /0111 -o -name \*.so\* \) ); do
126 patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true
127 patchelf --set-rpath $libPath:$out/opt/viber/lib $file || true
128 done
129
130 # qt.conf is not working, so override everything using environment variables
131 wrapProgram $out/opt/viber/Viber \
132 --set QT_QPA_PLATFORM "xcb" \
133 --set QT_PLUGIN_PATH "$out/opt/viber/plugins" \
134 --set QT_XKB_CONFIG_ROOT "${xorg.xkeyboardconfig}/share/X11/xkb" \
135 --set QTCOMPOSE "${xorg.libX11.out}/share/X11/locale" \
136 --set QML2_IMPORT_PATH "$out/opt/viber/qml"
137 ln -s $out/opt/viber/Viber $out/bin/viber
138
139 mv $out/usr/share $out/share
140 rm -rf $out/usr
141
142 # Fix the desktop link
143 substituteInPlace $out/share/applications/viber.desktop \
144 --replace /opt/viber/Viber $out/opt/viber/Viber \
145 --replace /usr/share/ $out/share/
146 '';
147
148 dontStrip = true;
149 dontPatchELF = true;
150
151 meta = {
152 homepage = "https://www.viber.com";
153 description = "Instant messaging and Voice over IP (VoIP) app";
154 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
155 license = lib.licenses.unfree;
156 platforms = [ "x86_64-linux" ];
157 maintainers = with lib.maintainers; [ jagajaga ];
158 };
159
160}