summary refs log tree commit diff
path: root/pkgs/applications/networking/instant-messengers/linphone/default.nix
blob: 5234c95bd6a8719b6cabad05b0f64a301bc335ad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
{ bcg729
, bctoolbox
, bcunit
, belcard
, belle-sip
, belr
, bzrtp
, cairo
, cmake
, cyrus_sasl
, fetchFromGitLab
, fetchurl
, ffmpeg
, gdk-pixbuf
, glib
, gnused
, graphviz
, gtk2
, intltool
, lib
, libexosip
, liblinphone
, libmatroska
, libnotify
, libosip
, libsoup
, libupnp
, libX11
, libxml2
, makeWrapper
, mbedtls
, mediastreamer
, mediastreamer-openh264
, minizip2
, mkDerivation
, openldap
, ortp
, pango
, pkg-config
, qtbase
, qtgraphicaleffects
, qtquickcontrols2
, qttranslations
, readline
, speex
, sqlite

, udev
, zlib
}:

# How to update Linphone? (The Qt desktop app)
#
# Belledonne Communications (BC), the company making Linphone, has split the
# project into several sub-projects that they maintain, plus some third-party
# dependencies that they also extend with commits of their own, specific to
# Linphone and not (yet?) upstreamed.
#
# All of this is organised in a Software Development Kit (SDK) meta-repository
# with git submodules to pin all those repositories into a coherent whole.
#
# The Linphone Qt desktop app uses this SDK as submodule as well.
#
# So, in order to update the desktop app to a new release, one has to follow
# the submodule chain and update the corresponding derivations here, in nixpkgs,
# with the corresponding version number (or commit hash)

mkDerivation rec {
  pname = "linphone-desktop";
  version = "4.4.1";

  src = fetchFromGitLab {
    domain = "gitlab.linphone.org";
    owner = "public";
    group = "BC";
    repo = pname;
    rev = version;
    sha256 = "sha256-BBOTyKMZikkxMJSmzAuChVHpVeCvbAimn1K3REGbqEg=";
  };

  patches = [
    ./do-not-build-linphone-sdk.patch
    ./remove-bc_compute_full_version-usage.patch
    ./no-store-path-in-autostart.patch
  ];

  # See: https://gitlab.linphone.org/BC/public/linphone-desktop/issues/21
  postPatch = ''
    echo "project(linphoneqt VERSION ${version})" >linphone-app/linphoneqt_version.cmake
    substituteInPlace linphone-app/src/app/AppController.cpp \
      --replace "LINPHONE_QT_GIT_VERSION" "\"${version}\""
  '';

  # TODO: After linphone-desktop and liblinphone split into separate packages,
  # there might be some build inputs here that aren't needed for
  # linphone-desktop.
  buildInputs = [
    # Made by BC
    bcg729
    bctoolbox
    belcard
    belle-sip
    belr
    bzrtp
    liblinphone
    mediastreamer
    mediastreamer-openh264
    ortp

    # Vendored by BC but we use upstream, might cause problems
    libmatroska

    cairo
    cyrus_sasl
    ffmpeg
    gdk-pixbuf
    glib
    gtk2
    libX11
    libexosip
    libnotify
    libosip
    libsoup
    libupnp
    libxml2
    mbedtls
    minizip2
    openldap
    pango
    qtbase
    qtgraphicaleffects
    qtquickcontrols2
    qttranslations
    readline
    speex
    sqlite
    udev
    zlib
  ];

  nativeBuildInputs = [
    # Made by BC
    bcunit

    cmake
    gnused
    graphviz
    intltool
    makeWrapper
    pkg-config
  ];

  cmakeFlags = [
    "-DMINIZIP_INCLUDE_DIRS=${minizip2}/include"
    "-DMINIZIP_LIBRARIES=minizip"
  ];

  # The default install phase fails because the paths are somehow messed up in
  # the makefiles. The errors were like:
  #
  #   CMake Error at cmake_builder/linphone_package/cmake_install.cmake:49 (file):
  #     file INSTALL cannot find
  #     "/build/linphone-desktop-.../build/linphone-sdk/desktop//nix/store/.../bin":
  #     No such file or directory.
  #
  # If someone is able to figure out how to fix that, great. For now, just
  # trying to pick all the relevant files to the output.
  #
  # Also, the exec path in linphone.desktop file remains invalid, pointing to
  # the build directory, after the whole nix build process. So, let's use sed to
  # manually fix that path.
  #
  # In order to find mediastreamer plugins, mediastreamer package was patched to
  # support an environment variable pointing to the plugin directory. Set that
  # environment variable by wrapping the Linphone executable.
  #
  # Also, some grammar files needed to be copied too from some dependencies. I
  # suppose if one define a dependency in such a way that its share directory is
  # found, then this copying would be unnecessary. These missing grammar files
  # were discovered when linphone crashed at startup and it was run with
  # --verbose flag. Instead of actually copying these files, create symlinks.
  #
  # It is quite likely that there are some other files still missing and
  # Linphone will randomly crash when it tries to access those files. Then,
  # those just need to be copied manually below.
  installPhase = ''
    mkdir -p $out/bin $out/lib
    cp linphone-app/linphone $out/bin/
    cp linphone-app/libapp-plugin.so $out/lib/
    mkdir -p $out/lib/mediastreamer/plugins
    ln -s ${mediastreamer-openh264}/lib/mediastreamer/plugins/* $out/lib/mediastreamer/plugins/
    ln -s ${mediastreamer}/lib/mediastreamer/plugins/* $out/lib/mediastreamer/plugins/
    wrapProgram $out/bin/linphone \
      --set MEDIASTREAMER_PLUGINS_DIR \
            $out/lib/mediastreamer/plugins
    mkdir -p $out/share/applications
    cp linphone-app/linphone.desktop $out/share/applications/
    mkdir -p $out/share/icons/hicolor/scalable/apps
    cp ../linphone-app/assets/images/linphone_logo.svg $out/share/icons/hicolor/scalable/apps/linphone.svg
    mkdir -p $out/share/belr/grammars
    ln -s ${liblinphone}/share/belr/grammars/* $out/share/belr/grammars/
    ln -s ${belle-sip}/share/belr/grammars/* $out/share/belr/grammars/
    mkdir -p $out/share/linphone
    ln -s ${liblinphone}/share/linphone/* $out/share/linphone/
    ln -s ${liblinphone}/share/sounds $out/share/sounds
  '';

  meta = with lib; {
    homepage = "https://www.linphone.org/";
    description = "Open source SIP phone for voice/video calls and instant messaging";
    license = licenses.gpl3Plus;
    platforms = platforms.linux;
    maintainers = with maintainers; [ jluttine ];
  };
}