photoqt: 4.6 -> 4.7 (#361171)
[NixPkgs.git] / pkgs / desktops / lomiri / services / telephony-service / default.nix
blobc7b3dbf27aebc514b88192e7946e5e2b240c58e8
2   stdenv,
3   lib,
4   fetchFromGitLab,
5   fetchpatch,
6   gitUpdater,
7   nixosTests,
8   ayatana-indicator-messages,
9   bash,
10   cmake,
11   dbus,
12   dbus-glib,
13   dbus-test-runner,
14   dconf,
15   gettext,
16   glib,
17   gnome-keyring,
18   libnotify,
19   libphonenumber,
20   libpulseaudio,
21   libusermetrics,
22   lomiri-history-service,
23   lomiri-url-dispatcher,
24   makeWrapper,
25   pkg-config,
26   protobuf,
27   python3,
28   qtbase,
29   qtdeclarative,
30   qtfeedback,
31   qtmultimedia,
32   qtpim,
33   telepathy,
34   telepathy-glib,
35   telepathy-mission-control,
36   xvfb-run,
39 let
40   replaceDbusService =
41     pkg: name:
42     "--replace-fail \"\\\${DBUS_SERVICES_DIR}/${name}\" \"${pkg}/share/dbus-1/services/${name}\"";
44 stdenv.mkDerivation (finalAttrs: {
45   pname = "telephony-service";
46   version = "0.5.3";
48   src = fetchFromGitLab {
49     owner = "ubports";
50     repo = "development/core/telephony-service";
51     rev = finalAttrs.version;
52     hash = "sha256-eLGwAJmBDDvSODQUNr/zcPA/0DdXtVBiS7vg+iIYPDo=";
53   };
55   patches = [
56     # Remove when https://gitlab.com/ubports/development/core/telephony-service/-/merge_requests/90 merged & in release
57     (fetchpatch {
58       name = "0001-lomiri-telephony-service-CMakeLists-Make-tests-optional.patch";
59       url = "https://gitlab.com/ubports/development/core/lomiri-telephony-service/-/commit/9a8297bcf9b34d77ffdae3dfe4ad2636022976fb.patch";
60       hash = "sha256-Za4ZGKnw9iz2RP1LzLhKrEJ1vLUufWk8J07LmWDW40E=";
61     })
63     # Remove when version > 0.5.3
64     (fetchpatch {
65       name = "0002-lomiri-telephony-service-Fix-gettext-funcs-in-wrong-namespace.patch";
66       url = "https://gitlab.com/ubports/development/core/lomiri-telephony-service/-/commit/18e0ba8e025b097eef1217d97d98ef4a4940fe84.patch";
67       hash = "sha256-vOIy+B/OQeccsVn4pXsnr8LYyEapqbebW1I6dBg5u2c=";
68     })
70     # Remove when version > 0.5.3
71     (fetchpatch {
72       name = "0003-lomiri-telephony-service-Handle-renamed-history-service.patch";
73       url = "https://gitlab.com/ubports/development/core/lomiri-telephony-service/-/commit/3a387670ed13041db069068292b1f41229e79583.patch";
74       hash = "sha256-b7gxzr6Mmtogclq3hR7a/zl+816H2wmJqv3oHjUJggw=";
75     })
76   ];
78   postPatch =
79     ''
80       # Queries qmake for the QML installation path, which returns a reference to Qt5's build directory
81       # Patch out failure if QMake is not found, since we don't use it
82       substituteInPlace CMakeLists.txt \
83         --replace-fail "\''${QMAKE_EXECUTABLE} -query QT_INSTALL_QML" "echo $out/${qtbase.qtQmlPrefix}" \
84         --replace-fail 'QMAKE_EXECUTABLE STREQUAL "QMAKE_EXECUTABLE-NOTFOUND"' 'FALSE'
86     ''
87     + lib.optionalString finalAttrs.finalPackage.doCheck ''
88       substituteInPlace tests/common/dbus-services/CMakeLists.txt \
89         ${replaceDbusService telepathy-mission-control "org.freedesktop.Telepathy.MissionControl5.service"} \
90         ${replaceDbusService telepathy-mission-control "org.freedesktop.Telepathy.AccountManager.service"} \
91         ${replaceDbusService dconf "ca.desrt.dconf.service"}
93       substituteInPlace cmake/modules/GenerateTest.cmake \
94         --replace-fail '/usr/lib/dconf' '${lib.getLib dconf}/libexec' \
95         --replace-fail '/usr/lib/telepathy' '${lib.getLib telepathy-mission-control}/libexec'
96     '';
98   strictDeps = true;
100   nativeBuildInputs = [
101     cmake
102     pkg-config
103     makeWrapper
104   ];
106   buildInputs = [
107     ayatana-indicator-messages
108     bash
109     dbus-glib
110     dbus
111     dconf
112     gettext
113     glib
114     libnotify
115     libphonenumber
116     libpulseaudio
117     libusermetrics
118     lomiri-history-service
119     lomiri-url-dispatcher
120     protobuf
121     (python3.withPackages (
122       ps: with ps; [
123         dbus-python
124         pygobject3
125       ]
126     ))
127     qtbase
128     qtdeclarative
129     qtfeedback
130     qtmultimedia
131     qtpim
132     telepathy
133     telepathy-glib
134     telepathy-mission-control
135   ];
137   nativeCheckInputs = [
138     dbus-test-runner
139     dconf
140     gnome-keyring
141     telepathy-mission-control
142     xvfb-run
143   ];
145   dontWrapQtApps = true;
147   cmakeFlags = [
148     # These rely on libphonenumber reformatting inputs to certain results
149     # Seem to be broken for a small amount of numbers, maybe libphonenumber version change?
150     (lib.cmakeBool "SKIP_QML_TESTS" true)
151     (lib.cmakeFeature "CMAKE_CTEST_ARGUMENTS" (
152       lib.concatStringsSep ";" [
153         # Exclude tests
154         "-E"
155         (lib.strings.escapeShellArg "(${
156           lib.concatStringsSep "|" [
157             # Flaky, randomly failing to launch properly & stuck until test timeout
158             # https://gitlab.com/ubports/development/core/lomiri-telephony-service/-/issues/70
159             "^HandlerTest"
160             "^OfonoAccountEntryTest"
161             "^TelepathyHelperSetupTest"
162             "^AuthHandlerTest"
163             "^ChatManagerTest"
164             "^AccountEntryTest"
165             "^AccountEntryFactoryTest"
166             "^PresenceRequestTest"
167             "^CallEntryTest"
168           ]
169         })")
170       ]
171     ))
172   ];
174   env.NIX_CFLAGS_COMPILE = toString ([
175     "-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
176     "-I${lib.getDev dbus-glib}/include/dbus-1.0" # telepathy-glib dependency
177     "-I${lib.getDev dbus}/include/dbus-1.0" # telepathy-glib dependency
178   ]);
180   doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
182   # Starts & talks to D-Bus services, breaks with parallelism
183   enableParallelChecking = false;
185   preCheck = ''
186     export QT_QPA_PLATFORM=minimal
187     export QT_PLUGIN_PATH=${
188       lib.makeSearchPathOutput "bin" qtbase.qtPluginPrefix [
189         qtbase
190         qtpim
191       ]
192     }
193   '';
195   postInstall = ''
196     patchShebangs $out/bin/{ofono-setup,phone-gsettings-migration.py}
198     # Still missing getprop from libhybris, we don't have it packaged (yet?)
199     wrapProgram $out/bin/ofono-setup \
200       --prefix PATH : ${
201         lib.makeBinPath [
202           dbus
203           dconf
204           gettext
205           glib
206           telepathy-mission-control
207         ]
208       }
210     # These SystemD services are referenced by the installed D-Bus services, but not part of the installation. Why?
211     for service in telephony-service-{approver,indicator}; do
212       install -Dm644 ../debian/telephony-service."$service".user.service $out/lib/systemd/user/"$service".service
214       # ofono-setup.service would be provided by ubuntu-touch-session, we don't plan to package it
215       # Doesn't make sense to provide on non-Lomiri
216       substituteInPlace $out/lib/systemd/user/"$service".service \
217         --replace-fail '/usr' "$out" \
218         --replace-warn 'Requires=ofono-setup.service' "" \
219         --replace-warn 'After=ofono-setup.service' "" \
220         --replace-warn 'WantedBy=ayatana-indicators.target' 'WantedBy=lomiri-indicators.target'
221     done
223     # Parses the call & SMS indicator desktop files & tries to find its own executable in PATH
224     wrapProgram $out/bin/telephony-service-indicator \
225       --prefix PATH : "$out/bin"
226   '';
228   passthru = {
229     ayatana-indicators = {
230       telephony-service-indicator = [ "lomiri" ];
231     };
232     tests.vm = nixosTests.ayatana-indicators;
233     updateScript = gitUpdater { };
234   };
236   meta = {
237     description = "Backend dispatcher service for various mobile phone related operations";
238     homepage = "https://gitlab.com/ubports/development/core/telephony-service";
239     changelog = "https://gitlab.com/ubports/development/core/telephony-service/-/blob/${finalAttrs.version}/ChangeLog";
240     license = lib.licenses.gpl3Only;
241     maintainers = lib.teams.lomiri.members;
242     platforms = lib.platforms.linux;
243   };