···1+{ bcg729
2+, bctoolbox
3+, bcunit
4+, belcard
5+, belle-sip
6+, belr
7+, bzrtp
8+, cairo
9+, cmake
10+, cyrus_sasl
11+, fetchFromGitLab
12+, fetchurl
13+, ffmpeg
14+, gdk-pixbuf
15+, glib
16+, gnused
17+, graphviz
18+, gtk2
19+, intltool
20+, lib
21+, libexosip
22+, liblinphone
23+, libmatroska
24+, libnotify
25+, libosip
26+, libsoup
27+, libupnp
28+, libX11
29+, libxml2
30+, makeWrapper
31+, mbedtls
32+, mediastreamer
33+, mediastreamer-openh264
34+, mkDerivation
35+, openldap
36+, ortp
37+, pango
38+, pkgconfig
39+, python
40+, qtbase
41+, qtgraphicaleffects
42+, qtquickcontrols2
43+, qttranslations
44+, readline
45+, speex
46+, sqlite
47+, stdenv
48+, udev
49+, zlib
50+ # For Minizip 2.2.7:
51+, fetchFromGitHub
52+, libbsd
53}:
54+let
55+ # Linphone Desktop requires Minizip 2.2.7. Nixpkgs contains a very old version
56+ # from the time when it was part of zlib. The most recent release of Minizip
57+ # is currently 2.9.2 but Linphone Desktop didn't work with that. So, even if
58+ # we added most recent Minizip version to nixpkgs, probably Minizip 2.2.7 is
59+ # only needed here and we shouldn't add this semi-old version to
60+ # all-packages.nix. Therefore, just define it here locally.
61+ minizip2 = stdenv.mkDerivation rec {
62+ pname = "minizip";
63+ version = "2.2.7";
6465+ disabled = stdenv.isAarch32;
66+67+ src = fetchFromGitHub {
68+ owner = "nmoinvaz";
69+ repo = pname;
70+ rev = version;
71+ sha256 = "1a88v1gjlflsd17mlrgxh420rpa38q0d17yh9q8j1zzqfrd1azch";
72+ };
73+74+ nativeBuildInputs = [ cmake pkgconfig ];
75+76+ cmakeFlags = [
77+ "-DBUILD_SHARED_LIBS=YES"
78+ ];
79+80+ buildInputs = [
81+ zlib
82+ libbsd # required in 2.2.7 but not in 2.9.2?
83+ ];
8485+ meta = with stdenv.lib; {
86+ description = "Compression library implementing the deflate compression method found in gzip and PKZIP";
87+ homepage = "https://github.com/nmoinvaz/minizip";
88+ license = licenses.zlib;
89+ platforms = platforms.unix;
90+ };
91+ };
92+in
93+mkDerivation rec {
94+ pname = "linphone-desktop";
95+ # Latest release is 4.1.1 old and doesn't build with the latest releases of
96+ # some of the dependencies so let's use the latest commit.
97+ version = "unstable-2020-03-06";
98+99+ src = fetchFromGitLab {
100+ domain = "gitlab.linphone.org";
101+ owner = "public";
102+ group = "BC";
103 repo = pname;
104+ rev = "971997e162558d37051f89c9c34bbc240135f704";
105+ sha256 = "02ji4r8bpcm2kyisn9d3054m026l33g2574i1ag1cmb2dz2p8i1c";
106 };
107108+ # Without this patch, the build fails with:
109+ #
110+ # No rule to make target
111+ # 'minizip_OUTPUT/nix/store/...linphone-desktop.../lib/libminizip.so',
112+ #
113+ # So, the makefile tries to use a full absolute path to the library but does
114+ # it incorrectly. As we have installed Minizip properly, it's sufficient to
115+ # just use "minizip" and the library is found automatically. If this patched
116+ # target_link_libraries line was removed entirely, the build would fail at the
117+ # very end when linking minizip.
118+ patches = [
119+ ./fix_minizip_linking.patch
120+ ];
121122+ # See: https://gitlab.linphone.org/BC/public/linphone-desktop/issues/21
123 postPatch = ''
124+ substituteInPlace src/app/AppController.cpp \
125+ --replace "LINPHONE_QT_GIT_VERSION" "\"${version}\""
126 '';
127128+ # TODO: After linphone-desktop and liblinphone split into separate packages,
129+ # there might be some build inputs here that aren't needed for
130+ # linphone-desktop.
131 buildInputs = [
132+ bcg729
133+ bctoolbox
134+ belcard
135+ belle-sip
136+ belr
137+ bzrtp
138+ cairo
139+ cyrus_sasl
140+ ffmpeg
141+ gdk-pixbuf
142+ glib
143+ gtk2
144+ libX11
145+ libexosip
146+ liblinphone
147+ libmatroska
148+ libnotify
149+ libosip
150+ libsoup
151+ libupnp
152+ libxml2
153+ mbedtls
154+ mediastreamer
155+ mediastreamer-openh264
156+ minizip2
157+ openldap
158+ ortp
159+ pango
160+ qtbase
161+ qtgraphicaleffects
162+ qtquickcontrols2
163+ qttranslations
164+ readline
165+ speex
166+ sqlite
167+ udev
168+ zlib
169 ];
170171 nativeBuildInputs = [
172+ bcunit
173+ cmake
174+ gnused
175+ graphviz
176+ intltool
177+ makeWrapper
178+ pkgconfig
179 ];
180181+ cmakeFlags = [
182+ "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
183+ "-DMINIZIP_INCLUDE_DIRS=${minizip2}/include"
184+ "-DMINIZIP_LIBRARIES=minizip"
00000185 ];
186187+ # The default install phase fails because the paths are somehow messed up in
188+ # the makefiles. The errors were like:
189+ #
190+ # CMake Error at cmake_builder/linphone_package/cmake_install.cmake:49 (file):
191+ # file INSTALL cannot find
192+ # "/build/linphone-desktop-.../build/linphone-sdk/desktop//nix/store/.../bin":
193+ # No such file or directory.
194+ #
195+ # If someone is able to figure out how to fix that, great. For now, just
196+ # trying to pick all the relevant files to the output.
197+ #
198+ # Also, the exec path in linphone.desktop file remains invalid, pointing to
199+ # the build directory, after the whole nix build process. So, let's use sed to
200+ # manually fix that path.
201+ #
202+ # In order to find mediastreamer plugins, mediastreamer package was patched to
203+ # support an environment variable pointing to the plugin directory. Set that
204+ # environment variable by wrapping the Linphone executable.
205+ #
206+ # Also, some grammar files needed to be copied too from some dependencies. I
207+ # suppose if one define a dependency in such a way that its share directory is
208+ # found, then this copying would be unnecessary. These missing grammar files
209+ # were discovered when linphone crashed at startup and it was run with
210+ # --verbose flag. Instead of actually copying these files, create symlinks.
211+ #
212+ # It is quite likely that there are some other files still missing and
213+ # Linphone will randomly crash when it tries to access those files. Then,
214+ # those just need to be copied manually below.
215+ installPhase = ''
216+ mkdir -p $out/bin
217+ cp linphone $out/bin/
218+ wrapProgram $out/bin/linphone \
219+ --set MEDIASTREAMER_PLUGINS_DIR \
220+ ${mediastreamer-openh264}/lib/mediastreamer/plugins
221+ mkdir -p $out/share/applications
222+ sed -i "s@/build/.*/OUTPUT/bin@$out/bin@" linphone.desktop
223+ cp linphone.desktop $out/share/applications/
224+ cp -r ../assets/icons $out/share/
225+ mkdir -p $out/share/belr/grammars
226+ ln -s ${belcard}/share/belr/grammars/* $out/share/belr/grammars/
227+ ln -s ${liblinphone}/share/belr/grammars/* $out/share/belr/grammars/
228+ mkdir -p $out/share/linphone
229+ ln -s ${liblinphone}/share/linphone/* $out/share/linphone/
230 '';
231232+ meta = with lib; {
233 homepage = https://www.linphone.org/;
234 description = "Open source SIP phone for voice/video calls and instant messaging";
235+ license = licenses.gpl3;
236 platforms = platforms.linux;
237+ maintainers = with maintainers; [ jluttine ];
238 };
239}