lomiri.telephony-service: nixfmt, modernise

This commit is contained in:
OPNA2608 2024-08-15 21:55:33 +02:00
parent 58265b002d
commit c07e19d8d0

View File

@ -1,42 +1,45 @@
{ 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
{
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}\"";
replaceDbusService =
pkg: name:
"--replace-fail \"\\\${DBUS_SERVICES_DIR}/${name}\" \"${pkg}/share/dbus-1/services/${name}\"";
in
stdenv.mkDerivation (finalAttrs: {
pname = "telephony-service";
@ -65,23 +68,25 @@ stdenv.mkDerivation (finalAttrs: {
})
];
postPatch = ''
# Queries qmake for the QML installation path, which returns a reference to Qt5's build directory
# Patch out failure if QMake is not found, since we don't use it
substituteInPlace CMakeLists.txt \
--replace "\''${QMAKE_EXECUTABLE} -query QT_INSTALL_QML" "echo $out/${qtbase.qtQmlPrefix}" \
--replace-fail 'QMAKE_EXECUTABLE STREQUAL "QMAKE_EXECUTABLE-NOTFOUND"' 'FALSE'
postPatch =
''
# Queries qmake for the QML installation path, which returns a reference to Qt5's build directory
# Patch out failure if QMake is not found, since we don't use it
substituteInPlace CMakeLists.txt \
--replace-fail "\''${QMAKE_EXECUTABLE} -query QT_INSTALL_QML" "echo $out/${qtbase.qtQmlPrefix}" \
--replace-fail 'QMAKE_EXECUTABLE STREQUAL "QMAKE_EXECUTABLE-NOTFOUND"' 'FALSE'
'' + 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"}
''
+ 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'
'';
substituteInPlace cmake/modules/GenerateTest.cmake \
--replace-fail '/usr/lib/dconf' '${lib.getLib dconf}/libexec' \
--replace-fail '/usr/lib/telepathy' '${lib.getLib telepathy-mission-control}/libexec'
'';
strictDeps = true;
@ -106,10 +111,12 @@ stdenv.mkDerivation (finalAttrs: {
libusermetrics
lomiri-url-dispatcher
protobuf
(python3.withPackages (ps: with ps; [
dbus-python
pygobject3
]))
(python3.withPackages (
ps: with ps; [
dbus-python
pygobject3
]
))
qtbase
qtdeclarative
qtfeedback
@ -134,22 +141,27 @@ stdenv.mkDerivation (finalAttrs: {
# 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
# https://gitlab.com/ubports/development/core/lomiri-telephony-service/-/issues/70
"^HandlerTest"
"^OfonoAccountEntryTest"
"^TelepathyHelperSetupTest"
"^AuthHandlerTest"
"^ChatManagerTest"
"^AccountEntryTest"
"^AccountEntryFactoryTest"
"^PresenceRequestTest"
"^CallEntryTest"
]})")
]))
(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
# https://gitlab.com/ubports/development/core/lomiri-telephony-service/-/issues/70
"^HandlerTest"
"^OfonoAccountEntryTest"
"^TelepathyHelperSetupTest"
"^AuthHandlerTest"
"^ChatManagerTest"
"^AccountEntryTest"
"^AccountEntryFactoryTest"
"^PresenceRequestTest"
"^CallEntryTest"
]
})")
]
))
];
env.NIX_CFLAGS_COMPILE = toString ([
@ -165,7 +177,12 @@ stdenv.mkDerivation (finalAttrs: {
preCheck = ''
export QT_QPA_PLATFORM=minimal
export QT_PLUGIN_PATH=${lib.makeSearchPathOutput "bin" qtbase.qtPluginPrefix [ qtbase qtpim ]}
export QT_PLUGIN_PATH=${
lib.makeSearchPathOutput "bin" qtbase.qtPluginPrefix [
qtbase
qtpim
]
}
'';
postInstall = ''
@ -173,20 +190,25 @@ stdenv.mkDerivation (finalAttrs: {
# 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 ]}
--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
# ofono-setup.service would be provided 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'
--replace-fail '/usr' "$out" \
--replace-warn 'Requires=ofono-setup.service' "" \
--replace-warn 'After=ofono-setup.service' ""
done
# Parses the call & SMS indicator desktop files & tries to find its own executable in PATH
@ -195,19 +217,17 @@ stdenv.mkDerivation (finalAttrs: {
'';
passthru = {
ayatana-indicators = [
"telephony-service-indicator"
];
ayatana-indicators = [ "telephony-service-indicator" ];
tests.vm = nixosTests.ayatana-indicators;
updateScript = gitUpdater { };
};
meta = with lib; {
meta = {
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;
license = lib.licenses.gpl3Only;
maintainers = lib.teams.lomiri.members;
platforms = lib.platforms.linux;
};
})