From fa4581f1efbc6315ab111f5c7ab3022c237f5a44 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Thu, 19 Oct 2023 20:14:54 +0200 Subject: [PATCH 1/3] ayatana-indicator-messages: init at 23.10.0 --- .../ay/ayatana-indicator-messages/package.nix | 143 ++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 pkgs/by-name/ay/ayatana-indicator-messages/package.nix diff --git a/pkgs/by-name/ay/ayatana-indicator-messages/package.nix b/pkgs/by-name/ay/ayatana-indicator-messages/package.nix new file mode 100644 index 000000000000..aa391bcc44d6 --- /dev/null +++ b/pkgs/by-name/ay/ayatana-indicator-messages/package.nix @@ -0,0 +1,143 @@ +{ stdenv +, lib +, fetchFromGitHub +, gitUpdater +, testers +, accountsservice +, cmake +, dbus-test-runner +, withDocumentation ? true +, docbook_xsl +, docbook_xml_dtd_45 +, glib +, gobject-introspection +, gtest +, gtk-doc +, intltool +, lomiri +, pkg-config +, python3 +, systemd +, vala +, wrapGAppsHook +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "ayatana-indicator-messages"; + version = "23.10.0"; + + src = fetchFromGitHub { + owner = "AyatanaIndicators"; + repo = "ayatana-indicator-messages"; + rev = finalAttrs.version; + hash = "sha256-FBJeP5hOXJcOk04cRJpw+oN7L3w3meDX3ivLmFWkhVI="; + }; + + outputs = [ + "out" + "dev" + ] ++ lib.optionals withDocumentation [ + "devdoc" + ]; + + postPatch = '' + # Uses pkg_get_variable, cannot substitute prefix with that + substituteInPlace data/CMakeLists.txt \ + --replace "\''${SYSTEMD_USER_DIR}" "$out/lib/systemd/user" + + # Bad concatenation + substituteInPlace libmessaging-menu/messaging-menu.pc.in \ + --replace "\''${exec_prefix}/@CMAKE_INSTALL_LIBDIR@" '@CMAKE_INSTALL_FULL_LIBDIR@' \ + --replace "\''${prefix}/@CMAKE_INSTALL_INCLUDEDIR@" '@CMAKE_INSTALL_FULL_INCLUDEDIR@' + '' + lib.optionalString (!withDocumentation) '' + sed -i CMakeLists.txt \ + '/add_subdirectory(doc)/d' + ''; + + strictDeps = true; + + nativeBuildInputs = [ + cmake + glib # For glib-compile-schemas + intltool + pkg-config + vala + wrapGAppsHook + ] ++ lib.optionals withDocumentation [ + docbook_xsl + docbook_xml_dtd_45 + gtk-doc + ]; + + buildInputs = [ + accountsservice + lomiri.cmake-extras + glib + gobject-introspection + systemd + ]; + + nativeCheckInputs = [ + (python3.withPackages (ps: with ps; [ + pygobject3 + python-dbusmock + ])) + ]; + + checkInputs = [ + dbus-test-runner + gtest + ]; + + cmakeFlags = [ + "-DENABLE_TESTS=${lib.boolToString finalAttrs.doCheck}" + "-DGSETTINGS_LOCALINSTALL=ON" + "-DGSETTINGS_COMPILE=ON" + ]; + + makeFlags = lib.optionals withDocumentation [ + # gtk-doc doesn't call ld with the correct arguments + # ld: ...: undefined reference to symbol 'strncpy@@GLIBC_2.2.5', 'qsort@@GLIBC_2.2.5' + "LD=${stdenv.cc.targetPrefix}cc" + ]; + + doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform; + + preCheck = '' + # test-client imports gir, whose solib entry points to final store location + install -Dm644 libmessaging-menu/libmessaging-menu.so.0.0.0 $out/lib/libmessaging-menu.so.0 + ''; + + postCheck = '' + # remove the above solib-installation, let it be done properly + rm -r $out + ''; + + preInstall = lib.optionalString withDocumentation '' + # installing regenerates docs, generated files are created without write permissions, errors out while trying to overwrite them + chmod +w doc/reference/html/* + ''; + + passthru = { + ayatana-indicators = [ + "ayatana-indicator-messages" + ]; + tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; + updateScript = gitUpdater { }; + }; + + meta = with lib; { + description = "Ayatana Indicator Messages Applet"; + longDescription = '' + The -messages Ayatana System Indicator is the messages menu indicator for Unity7, MATE and Lomiri (optionally for + others, e.g. XFCE, LXDE). + ''; + homepage = "https://github.com/AyatanaIndicators/ayatana-indicator-messages"; + license = licenses.gpl3Only; + platforms = platforms.linux; + maintainers = with maintainers; [ OPNA2608 ]; + pkgConfigModules = [ + "messaging-menu" + ]; + }; +}) From aba2b6d387dcbe2f8e06de7140442a8459220b34 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Thu, 19 Oct 2023 20:26:53 +0200 Subject: [PATCH 2/3] nixos/ayatana-indicators: init module --- nixos/modules/module-list.nix | 1 + .../services/desktops/ayatana-indicators.nix | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 nixos/modules/services/desktops/ayatana-indicators.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 2c06f4931725..438da244ab7d 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -437,6 +437,7 @@ ./services/databases/surrealdb.nix ./services/databases/victoriametrics.nix ./services/desktops/accountsservice.nix + ./services/desktops/ayatana-indicators.nix ./services/desktops/bamf.nix ./services/desktops/blueman.nix ./services/desktops/cpupower-gui.nix diff --git a/nixos/modules/services/desktops/ayatana-indicators.nix b/nixos/modules/services/desktops/ayatana-indicators.nix new file mode 100644 index 000000000000..abc687bbd43d --- /dev/null +++ b/nixos/modules/services/desktops/ayatana-indicators.nix @@ -0,0 +1,58 @@ +{ config +, pkgs +, lib +, ... +}: + +let + cfg = config.services.ayatana-indicators; +in +{ + options.services.ayatana-indicators = { + enable = lib.mkEnableOption (lib.mdDoc '' + Ayatana Indicators, a continuation of Canonical's Application Indicators + ''); + + packages = lib.mkOption { + type = lib.types.listOf lib.types.package; + default = [ ]; + example = lib.literalExpression "with pkgs; [ ayatana-indicator-messages ]"; + description = lib.mdDoc '' + List of packages containing Ayatana Indicator services + that should be brought up by the SystemD "ayatana-indicators" user target. + + Packages specified here must have passthru.ayatana-indicators set correctly. + + If, how, and where these indicators are displayed will depend on your DE. + ''; + }; + }; + + config = lib.mkIf cfg.enable { + environment = { + systemPackages = cfg.packages; + + pathsToLink = [ + "/share/ayatana" + ]; + }; + + # libayatana-common's ayatana-indicators.target with explicit Wants & Before to bring up requested indicator services + systemd.user.targets."ayatana-indicators" = + let + indicatorServices = lib.lists.flatten + (map + (pkg: + (map (ind: "${ind}.service") pkg.passthru.ayatana-indicators)) + cfg.packages); + in + { + description = "Target representing the lifecycle of the Ayatana Indicators. Each indicator should be bound to it in its individual service file"; + partOf = [ "graphical-session.target" ]; + wants = indicatorServices; + before = indicatorServices; + }; + }; + + meta.maintainers = with lib.maintainers; [ OPNA2608 ]; +} From 84605b10088d734ce7ec049acd69e7a78abe535a Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Fri, 20 Oct 2023 11:50:27 +0200 Subject: [PATCH 3/3] nixos/tests: Add ayatana-indicators test --- nixos/tests/all-tests.nix | 1 + nixos/tests/ayatana-indicators.nix | 71 +++++++++++++++++++ .../ay/ayatana-indicator-messages/package.nix | 6 +- 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 nixos/tests/ayatana-indicators.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 22371c9fec37..e9c3af1fba2f 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -124,6 +124,7 @@ in { authelia = handleTest ./authelia.nix {}; avahi = handleTest ./avahi.nix {}; avahi-with-resolved = handleTest ./avahi.nix { networkd = true; }; + ayatana-indicators = handleTest ./ayatana-indicators.nix {}; babeld = handleTest ./babeld.nix {}; bazarr = handleTest ./bazarr.nix {}; bcachefs = handleTestOn ["x86_64-linux" "aarch64-linux"] ./bcachefs.nix {}; diff --git a/nixos/tests/ayatana-indicators.nix b/nixos/tests/ayatana-indicators.nix new file mode 100644 index 000000000000..bc7ff75f390f --- /dev/null +++ b/nixos/tests/ayatana-indicators.nix @@ -0,0 +1,71 @@ +import ./make-test-python.nix ({ pkgs, lib, ... }: let + user = "alice"; +in { + name = "ayatana-indicators"; + + meta = { + maintainers = with lib.maintainers; [ OPNA2608 ]; + }; + + nodes.machine = { config, ... }: { + imports = [ + ./common/auto.nix + ./common/user-account.nix + ]; + + test-support.displayManager.auto = { + enable = true; + inherit user; + }; + + services.xserver = { + enable = true; + desktopManager.mate.enable = true; + displayManager.defaultSession = lib.mkForce "mate"; + }; + + services.ayatana-indicators = { + enable = true; + packages = with pkgs; [ + ayatana-indicator-messages + ]; + }; + + # Services needed by some indicators + services.accounts-daemon.enable = true; # messages + }; + + # 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; + in '' + start_all() + machine.wait_for_x() + + # Desktop environment should reach graphical-session.target + machine.wait_for_unit("graphical-session.target", "${user}") + + # MATE relies on XDG autostart to bring up the indicators. + # Not sure *when* XDG autostart fires them up, and awaiting pgrep success seems to misbehave? + 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 '' + machine.succeed("pgrep -f ${serviceExec}") + machine.succeed("pkill -f ${serviceExec}") + '')) + '' + + # Ayatana target is the preferred way of starting up indicators on SystemD session, the graphical session is responsible for starting this if it supports them. + # Mate currently doesn't do this, so start it manually for checking (https://github.com/mate-desktop/mate-indicator-applet/issues/63) + machine.systemctl("start ayatana-indicators.target", "${user}") + machine.wait_for_unit("ayatana-indicators.target", "${user}") + + # Let all indicator services do their startups, potential post-launch crash & restart cycles so we can properly check for failures + # Not sure if there's a better way of awaiting this without false-positive potential + machine.sleep(10) + + # Now check if all indicator services were brought up successfully + '' + runCommandPerIndicatorService (service: '' + machine.wait_for_unit("${service}", "${user}") + ''); +}) diff --git a/pkgs/by-name/ay/ayatana-indicator-messages/package.nix b/pkgs/by-name/ay/ayatana-indicator-messages/package.nix index aa391bcc44d6..936c39a7fdce 100644 --- a/pkgs/by-name/ay/ayatana-indicator-messages/package.nix +++ b/pkgs/by-name/ay/ayatana-indicator-messages/package.nix @@ -2,6 +2,7 @@ , lib , fetchFromGitHub , gitUpdater +, nixosTests , testers , accountsservice , cmake @@ -122,7 +123,10 @@ stdenv.mkDerivation (finalAttrs: { ayatana-indicators = [ "ayatana-indicator-messages" ]; - tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; + tests = { + pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; + vm = nixosTests.ayatana-indicators; + }; updateScript = gitUpdater { }; };