From c637680b5d5ab844db4d9e5c13da8056aa47ac3f Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Tue, 2 Jan 2024 18:33:16 +0100 Subject: [PATCH 1/3] lomiri.lomiri-indicator-network: init at 1.0.0 --- nixos/tests/ayatana-indicators.nix | 30 +++- pkgs/desktops/lomiri/default.nix | 1 + .../lomiri-indicator-network/default.nix | 138 ++++++++++++++++++ 3 files changed, 163 insertions(+), 6 deletions(-) create mode 100644 pkgs/desktops/lomiri/services/lomiri-indicator-network/default.nix diff --git a/nixos/tests/ayatana-indicators.nix b/nixos/tests/ayatana-indicators.nix index bc7ff75f390f..2111a4a65b92 100644 --- a/nixos/tests/ayatana-indicators.nix +++ b/nixos/tests/ayatana-indicators.nix @@ -4,7 +4,7 @@ in { name = "ayatana-indicators"; meta = { - maintainers = with lib.maintainers; [ OPNA2608 ]; + maintainers = lib.teams.lomiri.members; }; nodes.machine = { config, ... }: { @@ -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() @@ -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}") '')) + '' @@ -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}") ''); }) diff --git a/pkgs/desktops/lomiri/default.nix b/pkgs/desktops/lomiri/default.nix index 70caa9d64420..3e044ab69055 100644 --- a/pkgs/desktops/lomiri/default.nix +++ b/pkgs/desktops/lomiri/default.nix @@ -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 { }; }; diff --git a/pkgs/desktops/lomiri/services/lomiri-indicator-network/default.nix b/pkgs/desktops/lomiri/services/lomiri-indicator-network/default.nix new file mode 100644 index 000000000000..a1262ec6d5c8 --- /dev/null +++ b/pkgs/desktops/lomiri/services/lomiri-indicator-network/default.nix @@ -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}/../ 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" + ]; + }; +}) From 8a6daacde1b9c2e7d80d62f4dc6df11e9cb642e0 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Tue, 2 Jan 2024 18:33:49 +0100 Subject: [PATCH 2/3] lomiri.lomiri-indicator-network: 1.0.0 -> 1.0.1 --- .../lomiri-indicator-network/default.nix | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/pkgs/desktops/lomiri/services/lomiri-indicator-network/default.nix b/pkgs/desktops/lomiri/services/lomiri-indicator-network/default.nix index a1262ec6d5c8..87f0dff94c3f 100644 --- a/pkgs/desktops/lomiri/services/lomiri-indicator-network/default.nix +++ b/pkgs/desktops/lomiri/services/lomiri-indicator-network/default.nix @@ -1,12 +1,12 @@ { stdenv , lib , fetchFromGitLab -, fetchpatch , gitUpdater , nixosTests , testers , cmake , cmake-extras +, coreutils , dbus , doxygen , gettext @@ -30,13 +30,13 @@ stdenv.mkDerivation (finalAttrs: { pname = "lomiri-indicator-network"; - version = "1.0.0"; + version = "1.0.1"; src = fetchFromGitLab { owner = "ubports"; repo = "development/core/lomiri-indicator-network"; rev = finalAttrs.version; - hash = "sha256-JrxJsdLd35coEJ0nYcYtPRQONLfKciNmBbLqXrEaOX0="; + hash = "sha256-rJKWhW082ndVPEQHjuSriKtl0zQw86adxiINkZQq1hY="; }; outputs = [ @@ -45,20 +45,13 @@ stdenv.mkDerivation (finalAttrs: { "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 = '' + # Patch FHS paths + # DBUS_SESSION_BUS_SERVICES_DIR queried via pkg-config, prefix output path substituteInPlace data/CMakeLists.txt \ --replace '/usr/lib/systemd/user' "$out/lib/systemd/user" \ - --replace '/etc/xdg/autostart' "$out/etc/xdg/autostart" + --replace '/etc/xdg/autostart' "$out/etc/xdg/autostart" \ + --replace 'DESTINATION "''${DBUS_SESSION_BUS_SERVICES_DIR}"' 'DESTINATION "''${CMAKE_INSTALL_PREFIX}/''${DBUS_SESSION_BUS_SERVICES_DIR}"' # Don't disregard GNUInstallDirs requests, {DOCDIR}/../ to preserve preferred name substituteInPlace doc/CMakeLists.txt \ @@ -114,6 +107,11 @@ stdenv.mkDerivation (finalAttrs: { doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform; + postInstall = '' + substituteInPlace $out/etc/dbus-1/services/com.lomiri.connectivity1.service \ + --replace '/bin/false' '${lib.getExe' coreutils "false"}' + ''; + passthru = { ayatana-indicators = [ "lomiri-indicator-network" From 2abf14041bb97ab3e30af4e345ea2cafa6108ef6 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Tue, 16 Jan 2024 02:38:33 +0100 Subject: [PATCH 3/3] lomiri.lomiri-indicator-network: Fetch upstream-submitted patches, cleanups --- .../lomiri-indicator-network/default.nix | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/pkgs/desktops/lomiri/services/lomiri-indicator-network/default.nix b/pkgs/desktops/lomiri/services/lomiri-indicator-network/default.nix index 87f0dff94c3f..ccabf1da7eca 100644 --- a/pkgs/desktops/lomiri/services/lomiri-indicator-network/default.nix +++ b/pkgs/desktops/lomiri/services/lomiri-indicator-network/default.nix @@ -1,6 +1,7 @@ { stdenv , lib , fetchFromGitLab +, fetchpatch , gitUpdater , nixosTests , testers @@ -45,17 +46,28 @@ stdenv.mkDerivation (finalAttrs: { "doc" ]; - postPatch = '' - # Patch FHS paths - # DBUS_SESSION_BUS_SERVICES_DIR queried via pkg-config, prefix output path - substituteInPlace data/CMakeLists.txt \ - --replace '/usr/lib/systemd/user' "$out/lib/systemd/user" \ - --replace '/etc/xdg/autostart' "$out/etc/xdg/autostart" \ - --replace 'DESTINATION "''${DBUS_SESSION_BUS_SERVICES_DIR}"' 'DESTINATION "''${CMAKE_INSTALL_PREFIX}/''${DBUS_SESSION_BUS_SERVICES_DIR}"' + patches = [ + # Remove when version > 1.0.1 + (fetchpatch { + name = "0001-lomiri-indicator-network-Make-less-assumptions-about-where-files-will-end-up.patch"; + url = "https://gitlab.com/ubports/development/core/lomiri-indicator-network/-/commit/065212b22ab9aa8d25a61b5482ad6511e4c8510b.patch"; + hash = "sha256-WrDTBKusK1808W8LZRGWaTOExu7gKpYBvkQ8hzoHoHk="; + }) - # Don't disregard GNUInstallDirs requests, {DOCDIR}/../ 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' + # Remove when version > 1.0.1 + (fetchpatch { + name = "0002-lomiri-indicator-network-Honour-CMAKE_INSTALL_DOCDIR_fordocumentation-installation.patch"; + url = "https://gitlab.com/ubports/development/core/lomiri-indicator-network/-/commit/79b9e12313f765ab6e95b4d4dfefbdbca50ef3c6.patch"; + hash = "sha256-vRfdegEi892UlrC9c1+5Td7CHLh7u0foPggLNBfc8lw="; + }) + ]; + + postPatch = '' + # Queried via pkg-config, would need to override a prefix variable + # Needs CMake 3.28 or higher to do as part of the call, https://github.com/NixOS/nixpkgs/pull/275284 + substituteInPlace data/CMakeLists.txt \ + --replace 'pkg_get_variable(DBUS_SESSION_BUS_SERVICES_DIR dbus-1 session_bus_services_dir)' 'set(DBUS_SESSION_BUS_SERVICES_DIR "''${CMAKE_INSTALL_SYSCONFDIR}/dbus-1/services")' \ + --replace 'pkg_get_variable(SYSTEMD_USER_DIR systemd systemduserunitdir)' 'set(SYSTEMD_USER_DIR "''${CMAKE_INSTALL_PREFIX}/lib/systemd/user")' ''; strictDeps = true; @@ -98,11 +110,11 @@ stdenv.mkDerivation (finalAttrs: { 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 + (lib.cmakeBool "GSETTINGS_LOCALINSTALL" true) + (lib.cmakeBool "GSETTINGS_COMPILE" true) + (lib.cmakeBool "ENABLE_TESTS" finalAttrs.doCheck) + (lib.cmakeBool "ENABLE_UBUNTU_COMPAT" true) # just in case something needs it + (lib.cmakeBool "BUILD_DOC" true) # lacks QML docs, needs qdoc: https://github.com/NixOS/nixpkgs/pull/245379 ]; doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;