biome: 1.9.2 -> 1.9.3
[NixPkgs.git] / pkgs / desktops / lomiri / services / telephony-service / default.nix
blob0735f56ce794517400a07873903f59d47e8d250a
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   history-service,
19   libnotify,
20   libphonenumber,
21   libpulseaudio,
22   libusermetrics,
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     })
69   ];
71   postPatch =
72     ''
73       # Queries qmake for the QML installation path, which returns a reference to Qt5's build directory
74       # Patch out failure if QMake is not found, since we don't use it
75       substituteInPlace CMakeLists.txt \
76         --replace-fail "\''${QMAKE_EXECUTABLE} -query QT_INSTALL_QML" "echo $out/${qtbase.qtQmlPrefix}" \
77         --replace-fail 'QMAKE_EXECUTABLE STREQUAL "QMAKE_EXECUTABLE-NOTFOUND"' 'FALSE'
79     ''
80     + lib.optionalString finalAttrs.finalPackage.doCheck ''
81       substituteInPlace tests/common/dbus-services/CMakeLists.txt \
82         ${replaceDbusService telepathy-mission-control "org.freedesktop.Telepathy.MissionControl5.service"} \
83         ${replaceDbusService telepathy-mission-control "org.freedesktop.Telepathy.AccountManager.service"} \
84         ${replaceDbusService dconf "ca.desrt.dconf.service"}
86       substituteInPlace cmake/modules/GenerateTest.cmake \
87         --replace-fail '/usr/lib/dconf' '${lib.getLib dconf}/libexec' \
88         --replace-fail '/usr/lib/telepathy' '${lib.getLib telepathy-mission-control}/libexec'
89     '';
91   strictDeps = true;
93   nativeBuildInputs = [
94     cmake
95     pkg-config
96     makeWrapper
97   ];
99   buildInputs = [
100     ayatana-indicator-messages
101     bash
102     dbus-glib
103     dbus
104     dconf
105     gettext
106     glib
107     history-service
108     libnotify
109     libphonenumber
110     libpulseaudio
111     libusermetrics
112     lomiri-url-dispatcher
113     protobuf
114     (python3.withPackages (
115       ps: with ps; [
116         dbus-python
117         pygobject3
118       ]
119     ))
120     qtbase
121     qtdeclarative
122     qtfeedback
123     qtmultimedia
124     qtpim
125     telepathy
126     telepathy-glib
127     telepathy-mission-control
128   ];
130   nativeCheckInputs = [
131     dbus-test-runner
132     dconf
133     gnome-keyring
134     telepathy-mission-control
135     xvfb-run
136   ];
138   dontWrapQtApps = true;
140   cmakeFlags = [
141     # These rely on libphonenumber reformatting inputs to certain results
142     # Seem to be broken for a small amount of numbers, maybe libphonenumber version change?
143     (lib.cmakeBool "SKIP_QML_TESTS" true)
144     (lib.cmakeFeature "CMAKE_CTEST_ARGUMENTS" (
145       lib.concatStringsSep ";" [
146         # Exclude tests
147         "-E"
148         (lib.strings.escapeShellArg "(${
149           lib.concatStringsSep "|" [
150             # Flaky, randomly failing to launch properly & stuck until test timeout
151             # https://gitlab.com/ubports/development/core/lomiri-telephony-service/-/issues/70
152             "^HandlerTest"
153             "^OfonoAccountEntryTest"
154             "^TelepathyHelperSetupTest"
155             "^AuthHandlerTest"
156             "^ChatManagerTest"
157             "^AccountEntryTest"
158             "^AccountEntryFactoryTest"
159             "^PresenceRequestTest"
160             "^CallEntryTest"
161           ]
162         })")
163       ]
164     ))
165   ];
167   env.NIX_CFLAGS_COMPILE = toString ([
168     "-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
169     "-I${lib.getDev dbus-glib}/include/dbus-1.0" # telepathy-glib dependency
170     "-I${lib.getDev dbus}/include/dbus-1.0" # telepathy-glib dependency
171   ]);
173   doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
175   # Starts & talks to D-Bus services, breaks with parallelism
176   enableParallelChecking = false;
178   preCheck = ''
179     export QT_QPA_PLATFORM=minimal
180     export QT_PLUGIN_PATH=${
181       lib.makeSearchPathOutput "bin" qtbase.qtPluginPrefix [
182         qtbase
183         qtpim
184       ]
185     }
186   '';
188   postInstall = ''
189     patchShebangs $out/bin/{ofono-setup,phone-gsettings-migration.py}
191     # Still missing getprop from libhybris, we don't have it packaged (yet?)
192     wrapProgram $out/bin/ofono-setup \
193       --prefix PATH : ${
194         lib.makeBinPath [
195           dbus
196           dconf
197           gettext
198           glib
199           telepathy-mission-control
200         ]
201       }
203     # These SystemD services are referenced by the installed D-Bus services, but not part of the installation. Why?
204     for service in telephony-service-{approver,indicator}; do
205       install -Dm644 ../debian/telephony-service."$service".user.service $out/lib/systemd/user/"$service".service
207       # ofono-setup.service would be provided by ubuntu-touch-session, we don't plan to package it
208       # Doesn't make sense to provide on non-Lomiri
209       substituteInPlace $out/lib/systemd/user/"$service".service \
210         --replace-fail '/usr' "$out" \
211         --replace-warn 'Requires=ofono-setup.service' "" \
212         --replace-warn 'After=ofono-setup.service' "" \
213         --replace-warn 'WantedBy=ayatana-indicators.target' 'WantedBy=lomiri-indicators.target'
214     done
216     # Parses the call & SMS indicator desktop files & tries to find its own executable in PATH
217     wrapProgram $out/bin/telephony-service-indicator \
218       --prefix PATH : "$out/bin"
219   '';
221   passthru = {
222     ayatana-indicators = {
223       telephony-service-indicator = [ "lomiri" ];
224     };
225     tests.vm = nixosTests.ayatana-indicators;
226     updateScript = gitUpdater { };
227   };
229   meta = {
230     description = "Backend dispatcher service for various mobile phone related operations";
231     homepage = "https://gitlab.com/ubports/development/core/telephony-service";
232     changelog = "https://gitlab.com/ubports/development/core/telephony-service/-/blob/${finalAttrs.version}/ChangeLog";
233     license = lib.licenses.gpl3Only;
234     maintainers = lib.teams.lomiri.members;
235     platforms = lib.platforms.linux;
236   };