Skip to content

Commit

Permalink
lomiri.lomiri-indicator-network: init at 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
OPNA2608 committed Jan 2, 2024
1 parent cb12e9b commit c637680
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 6 deletions.
30 changes: 24 additions & 6 deletions nixos/tests/ayatana-indicators.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ in {
name = "ayatana-indicators";

meta = {
maintainers = with lib.maintainers; [ OPNA2608 ];
maintainers = lib.teams.lomiri.members;
};

nodes.machine = { config, ... }: {
Expand All @@ -28,16 +28,34 @@ in {
enable = true;
packages = with pkgs; [
ayatana-indicator-messages
];
] ++ (with pkgs.lomiri; [
lomiri-indicator-network
]);
};

# Services needed by some indicators
# Setup needed by some indicators

services.accounts-daemon.enable = true; # messages

# Lomiri-ish setup for Lomiri indicators
# TODO move into a Lomiri module, once the package set is far enough for the DE to start

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

# 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?
testScript = { nodes, ... }: let
runCommandPerIndicatorService = command: lib.strings.concatMapStringsSep "\n" command nodes.machine.systemd.user.targets."ayatana-indicators".wants;
runCommandOverServiceList = list: command:
lib.strings.concatMapStringsSep "\n" command list;

runCommandOverAyatanaIndicators = runCommandOverServiceList
(builtins.filter
(service: !(lib.strings.hasPrefix "lomiri" service || lib.strings.hasPrefix "telephony-service" service))
nodes.machine.systemd.user.targets."ayatana-indicators".wants);

runCommandOverAllIndicators = runCommandOverServiceList
nodes.machine.systemd.user.targets."ayatana-indicators".wants;
in ''
start_all()
machine.wait_for_x()
Expand All @@ -50,7 +68,7 @@ in {
machine.sleep(10)
# Now check if all indicators were brought up successfully, and kill them for later
'' + (runCommandPerIndicatorService (service: let serviceExec = builtins.replaceStrings [ "." ] [ "-" ] service; in ''
'' + (runCommandOverAyatanaIndicators (service: let serviceExec = builtins.replaceStrings [ "." ] [ "-" ] service; in ''
machine.succeed("pgrep -f ${serviceExec}")
machine.succeed("pkill -f ${serviceExec}")
'')) + ''
Expand All @@ -65,7 +83,7 @@ in {
machine.sleep(10)
# Now check if all indicator services were brought up successfully
'' + runCommandPerIndicatorService (service: ''
'' + runCommandOverAllIndicators (service: ''
machine.wait_for_unit("${service}", "${user}")
'');
})
1 change: 1 addition & 0 deletions pkgs/desktops/lomiri/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ let
hfd-service = callPackage ./services/hfd-service { };
history-service = callPackage ./services/history-service { };
lomiri-download-manager = callPackage ./services/lomiri-download-manager { };
lomiri-indicator-network = callPackage ./services/lomiri-indicator-network { };
lomiri-url-dispatcher = callPackage ./services/lomiri-url-dispatcher { };
mediascanner2 = callPackage ./services/mediascanner2 { };
};
Expand Down
138 changes: 138 additions & 0 deletions pkgs/desktops/lomiri/services/lomiri-indicator-network/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{ stdenv
, lib
, fetchFromGitLab
, fetchpatch
, gitUpdater
, nixosTests
, testers
, cmake
, cmake-extras
, dbus
, doxygen
, gettext
, glib
, gmenuharness
, gtest
, intltool
, libsecret
, libqofono
, libqtdbusmock
, libqtdbustest
, lomiri-api
, lomiri-url-dispatcher
, networkmanager
, ofono
, pkg-config
, python3
, qtdeclarative
, qtbase
}:

stdenv.mkDerivation (finalAttrs: {
pname = "lomiri-indicator-network";
version = "1.0.0";

src = fetchFromGitLab {
owner = "ubports";
repo = "development/core/lomiri-indicator-network";
rev = finalAttrs.version;
hash = "sha256-JrxJsdLd35coEJ0nYcYtPRQONLfKciNmBbLqXrEaOX0=";
};

outputs = [
"out"
"dev"
"doc"
];

patches = [
# Fix pkg-config file
# Remove when version > 1.0.0
(fetchpatch {
name = "0001-lomiri-indicator-network-Fix-pkg-config-file-for-liblomiri-connectivity-qt1.patch";
url = "https://gitlab.com/ubports/development/core/lomiri-indicator-network/-/commit/a67ac8e1a1b96f4dcad01dd4c1685fed9831eaa3.patch";
hash = "sha256-D3AhEJus0MysmfMg7eWFNI20Z5cTeHwiFTP0OuoQook=";
})
];

postPatch = ''
substituteInPlace data/CMakeLists.txt \
--replace '/usr/lib/systemd/user' "$out/lib/systemd/user" \
--replace '/etc/xdg/autostart' "$out/etc/xdg/autostart"
# Don't disregard GNUInstallDirs requests, {DOCDIR}/../<different-name> to preserve preferred name
substituteInPlace doc/CMakeLists.txt \
--replace 'INSTALL_DOCDIR ''${CMAKE_INSTALL_DATAROOTDIR}/doc/lomiri-connectivity-doc' 'INSTALL_DOCDIR ''${CMAKE_INSTALL_DOCDIR}/../lomiri-connectivity-doc'
'';

strictDeps = true;

nativeBuildInputs = [
cmake
doxygen
gettext
intltool
pkg-config
qtdeclarative
];

buildInputs = [
cmake-extras
dbus
glib
libqofono
libsecret
lomiri-api
lomiri-url-dispatcher
networkmanager
ofono
qtbase
];

nativeCheckInputs = [
(python3.withPackages (ps: with ps; [
python-dbusmock
]))
];

checkInputs = [
gmenuharness
gtest
libqtdbusmock
libqtdbustest
];

dontWrapQtApps = true;

cmakeFlags = [
"-DGSETTINGS_LOCALINSTALL=ON"
"-DGSETTINGS_COMPILE=ON"
"-DENABLE_TESTS=${lib.boolToString finalAttrs.doCheck}"
"-DENABLE_UBUNTU_COMPAT=ON" # in case
"-DBUILD_DOC=ON" # lacks QML docs, needs qdoc: https://github.com/NixOS/nixpkgs/pull/245379
];

doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;

passthru = {
ayatana-indicators = [
"lomiri-indicator-network"
];
tests = {
pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
vm = nixosTests.ayatana-indicators;
};
updateScript = gitUpdater { };
};

meta = with lib; {
description = "Ayatana indiator exporting the network settings menu through D-Bus";
homepage = "https://gitlab.com/ubports/development/core/lomiri-indicator-network";
license = licenses.gpl3Only;
maintainers = teams.lomiri.members;
platforms = platforms.linux;
pkgConfigModules = [
"lomiri-connectivity-qt1"
];
};
})

0 comments on commit c637680

Please sign in to comment.