Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lomiri.telephony-service: init at 0.5.2 #264844

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion nixos/tests/ayatana-indicators.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ in {
ayatana-indicator-messages
] ++ (with pkgs.lomiri; [
lomiri-indicator-network
telephony-service
]);
};

Expand All @@ -42,6 +43,25 @@ in {

networking.networkmanager.enable = true; # lomiri-network-indicator
# TODO potentially urfkill for lomiri-network-indicator?

services.dbus.packages = with pkgs.lomiri; [
libusermetrics
];

environment.systemPackages = with pkgs.lomiri; [
lomiri-schemas
];

services.telepathy.enable = true;

users.users.usermetrics = {
group = "usermetrics";
home = "/var/lib/usermetrics";
createHome = true;
isSystemUser = true;
};

users.groups.usermetrics = { };
};

# TODO session indicator starts up in a semi-broken state, but works fine after a restart. maybe being started before graphical session is truly up & ready?
Expand Down Expand Up @@ -69,7 +89,7 @@ in {

# Now check if all indicators were brought up successfully, and kill them for later
'' + (runCommandOverAyatanaIndicators (service: let serviceExec = builtins.replaceStrings [ "." ] [ "-" ] service; in ''
machine.succeed("pgrep -f ${serviceExec}")
machine.succeed("pgrep -u ${user} -f ${serviceExec}")
machine.succeed("pkill -f ${serviceExec}")
'')) + ''

Expand Down
1 change: 1 addition & 0 deletions pkgs/desktops/lomiri/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ let
lomiri-indicator-network = callPackage ./services/lomiri-indicator-network { };
lomiri-url-dispatcher = callPackage ./services/lomiri-url-dispatcher { };
mediascanner2 = callPackage ./services/mediascanner2 { };
telephony-service = callPackage ./services/telephony-service { };
};
in
lib.makeScope libsForQt5.newScope packages
227 changes: 227 additions & 0 deletions pkgs/desktops/lomiri/services/telephony-service/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
{ stdenv
, lib
, fetchFromGitLab
, fetchpatch
, fetchpatch2
, gitUpdater
, nixosTests
, ayatana-indicator-messages
, bash
, cmake
, dbus
, dbus-glib
, dbus-test-runner
, dconf
, gettext
, glib
, gnome
, history-service
, libnotify
, libphonenumber
, libpulseaudio
, libusermetrics
, lomiri-ui-toolkit
, 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.2";

src = fetchFromGitLab {
owner = "ubports";
repo = "development/core/telephony-service";
rev = finalAttrs.version;
hash = "sha256-9KxM8UWTIBpMMPosar2ZV9W35WmCLIWXD1ulWtqCKxM=";
};

patches = [
# Remove when version > 0.5.2
(fetchpatch {
name = "0001-telephony-service-CMakeLists-Fix-Cross-conditional-for-QT_INSTALL_QML-determining.patch";
url = "https://gitlab.com/ubports/development/core/telephony-service/-/commit/c19463444af257c263f35127284d9787f3522f1f.patch";
hash = "sha256-Dr/uev/z4pEiV4/QRmQ15+6wrD8rh+8vRcfWIi8FBCU=";
})

# Remove when version > 0.5.2
(fetchpatch {
name = "0002-telephony-service-tests-libtelephonyservice-CMakeLists-Fix-ProtocolTest-build.patch";
url = "https://gitlab.com/ubports/development/core/telephony-service/-/commit/d8f0f38f8b723569c03d601ac803b079ed51d09e.patch";
hash = "sha256-asDEzh8Yg6LXl6fdwan6IhwLEuzmDfmHI+pjpxJRbeE=";
})

# Remove when https://gitlab.com/ubports/development/core/telephony-service/-/merge_requests/89 merged & in release
(fetchpatch2 {
name = "0003-telephony-service-Add-more-better-GNUInstallDirs-variables-usage.patch";
url = "https://gitlab.com/ubports/development/core/telephony-service/-/commit/9a35a50c587ebfdfb1e08b54ffec0d2e6fef1950.patch";
hash = "sha256-jGeJlwbyVr0WkyGKY7Lw5dY/V9yN43DpZmuli6oRho0=";
})

# Remove when https://gitlab.com/ubports/development/core/telephony-service/-/merge_requests/90 merged & in release
(fetchpatch {
name = "0004-telephony-service-CMakeLists-Make-tests-optional.patch";
url = "https://gitlab.com/ubports/development/core/telephony-service/-/commit/9a8297bcf9b34d77ffdae3dfe4ad2636022976fb.patch";
hash = "sha256-Za4ZGKnw9iz2RP1LzLhKrEJ1vLUufWk8J07LmWDW40E=";
})

# libphonenumber -> protobuf -> abseil-cpp demands C++14
# But uses std::string_view which is C++17?
# Remove when version > 0.5.2
(fetchpatch {
name = "0005-telephony-service-Upgrade-C++-standard-to-C++17.patch";
url = "https://gitlab.com/ubports/development/core/telephony-service/-/commit/b77349acb4ab3f857a55481eeaf2af1dcecfb775.patch";
hash = "sha256-vNtelYu/I9lv8EkNn8gB6zNgLJ24Znp9HYmLG9olFe8=";
})
];

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.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
'';

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;
};
})