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
|
{ stdenv
, lib
, fetchFromGitLab
, fetchpatch
, gitUpdater
, nixosTests
, ayatana-indicator-messages
, bash
, cmake
, dbus
, dbus-glib
, dbus-test-runner
, dconf
, gettext
, glib
, gnome-keyring
, history-service
, libnotify
, libphonenumber
, libpulseaudio
, libusermetrics
, lomiri-url-dispatcher
, makeWrapper
, pkg-config
, protobuf
, python3
, qtbase
, qtdeclarative
, qtfeedback
, qtmultimedia
, qtpim
, telepathy
, telepathy-glib
, telepathy-mission-control
, xvfb-run
}:
let
replaceDbusService = pkg: name: "--replace \"\\\${DBUS_SERVICES_DIR}/${name}\" \"${pkg}/share/dbus-1/services/${name}\"";
in
stdenv.mkDerivation (finalAttrs: {
pname = "telephony-service";
version = "0.5.3";
src = fetchFromGitLab {
owner = "ubports";
repo = "development/core/telephony-service";
rev = finalAttrs.version;
hash = "sha256-eLGwAJmBDDvSODQUNr/zcPA/0DdXtVBiS7vg+iIYPDo=";
};
patches = [
# Remove when https://gitlab.com/ubports/development/core/telephony-service/-/merge_requests/90 merged & in release
(fetchpatch {
name = "0001-lomiri-telephony-service-CMakeLists-Make-tests-optional.patch";
url = "https://gitlab.com/ubports/development/core/lomiri-telephony-service/-/commit/9a8297bcf9b34d77ffdae3dfe4ad2636022976fb.patch";
hash = "sha256-Za4ZGKnw9iz2RP1LzLhKrEJ1vLUufWk8J07LmWDW40E=";
})
# Remove when version > 0.5.3
(fetchpatch {
name = "0002-lomiri-telephony-service-Fix-gettext-funcs-in-wrong-namespace.patch";
url = "https://gitlab.com/ubports/development/core/lomiri-telephony-service/-/commit/18e0ba8e025b097eef1217d97d98ef4a4940fe84.patch";
hash = "sha256-vOIy+B/OQeccsVn4pXsnr8LYyEapqbebW1I6dBg5u2c=";
})
];
postPatch = ''
# Queries qmake for the QML installation path, which returns a reference to Qt5's build directory
substituteInPlace CMakeLists.txt \
--replace "\''${QMAKE_EXECUTABLE} -query QT_INSTALL_QML" "echo $out/${qtbase.qtQmlPrefix}"
'' + lib.optionalString finalAttrs.finalPackage.doCheck ''
substituteInPlace tests/common/dbus-services/CMakeLists.txt \
${replaceDbusService telepathy-mission-control "org.freedesktop.Telepathy.MissionControl5.service"} \
${replaceDbusService telepathy-mission-control "org.freedesktop.Telepathy.AccountManager.service"} \
${replaceDbusService dconf "ca.desrt.dconf.service"}
substituteInPlace cmake/modules/GenerateTest.cmake \
--replace '/usr/lib/dconf' '${lib.getLib dconf}/libexec' \
--replace '/usr/lib/telepathy' '${lib.getLib telepathy-mission-control}/libexec'
'';
strictDeps = true;
nativeBuildInputs = [
cmake
pkg-config
makeWrapper
];
buildInputs = [
ayatana-indicator-messages
bash
dbus-glib
dbus
dconf
gettext
glib
history-service
libnotify
libphonenumber
libpulseaudio
libusermetrics
lomiri-url-dispatcher
protobuf
(python3.withPackages (ps: with ps; [
dbus-python
pygobject3
]))
qtbase
qtdeclarative
qtfeedback
qtmultimedia
qtpim
telepathy
telepathy-glib
telepathy-mission-control
];
nativeCheckInputs = [
dbus-test-runner
dconf
gnome-keyring
telepathy-mission-control
xvfb-run
];
dontWrapQtApps = true;
cmakeFlags = [
# These rely on libphonenumber reformatting inputs to certain results
# Seem to be broken for a small amount of numbers, maybe libphonenumber version change?
(lib.cmakeBool "SKIP_QML_TESTS" true)
(lib.cmakeFeature "CMAKE_CTEST_ARGUMENTS" (lib.concatStringsSep ";" [
# Exclude tests
"-E" (lib.strings.escapeShellArg "(${lib.concatStringsSep "|" [
# Flaky, randomly failing to launch properly & stuck until test timeout
"^HandlerTest"
"^OfonoAccountEntryTest"
"^TelepathyHelperSetupTest"
"^AuthHandlerTest"
"^ChatManagerTest"
]})")
]))
];
env.NIX_CFLAGS_COMPILE = toString ([
"-I${lib.getDev telepathy-glib}/include/telepathy-1.0" # it's in telepathy-farstream's Requires.private, so it & its dependencies don't get pulled in
"-I${lib.getDev dbus-glib}/include/dbus-1.0" # telepathy-glib dependency
"-I${lib.getDev dbus}/include/dbus-1.0" # telepathy-glib dependency
]);
doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
# Starts & talks to D-Bus services, breaks with parallelism
enableParallelChecking = false;
preCheck = ''
export QT_QPA_PLATFORM=minimal
export QT_PLUGIN_PATH=${lib.makeSearchPathOutput "bin" qtbase.qtPluginPrefix [ qtbase qtpim ]}
'';
postInstall = ''
patchShebangs $out/bin/{ofono-setup,phone-gsettings-migration.py}
# Still missing getprop from libhybris, we don't have it packaged (yet?)
wrapProgram $out/bin/ofono-setup \
--prefix PATH : ${lib.makeBinPath [ dbus dconf gettext glib telepathy-mission-control ]}
# These SystemD services are referenced by the installed D-Bus services, but not part of the installation. Why?
for service in telephony-service-{approver,indicator}; do
install -Dm644 ../debian/telephony-service."$service".user.service $out/lib/systemd/user/"$service".service
# ofono-setup.service would be rovided by ubuntu-touch-session, we don't plan to package it
substituteInPlace $out/lib/systemd/user/"$service".service \
--replace '/usr' "$out" \
--replace 'Requires=ofono-setup.service' "" \
--replace 'After=ofono-setup.service' "" \
sed -i $out/lib/systemd/user/"$service".service \
-e '/ofono-setup.service/d'
done
# Parses the call & SMS indicator desktop files & tries to find its own executable in PATH
wrapProgram $out/bin/telephony-service-indicator \
--prefix PATH : "$out/bin"
'';
passthru = {
ayatana-indicators = [
"telephony-service-indicator"
];
tests.vm = nixosTests.ayatana-indicators;
updateScript = gitUpdater { };
};
meta = with lib; {
description = "Backend dispatcher service for various mobile phone related operations";
homepage = "https://gitlab.com/ubports/development/core/telephony-service";
changelog = "https://gitlab.com/ubports/development/core/telephony-service/-/blob/${finalAttrs.version}/ChangeLog";
license = licenses.gpl3Only;
maintainers = teams.lomiri.members;
platforms = platforms.linux;
};
})
|