nixos/ayatana-indicators: Support new passthru.ayatana-indicators format

This commit is contained in:
OPNA2608 2024-08-15 20:52:04 +02:00
parent fd61e57735
commit 4403f7f6c3

View File

@ -20,11 +20,12 @@ in
example = lib.literalExpression "with pkgs; [ ayatana-indicator-messages ]";
description = ''
List of packages containing Ayatana Indicator services
that should be brought up by the SystemD "ayatana-indicators" user target.
that should be brought up by a 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.
Which target they will be brought up by depends on the packages' passthru.ayatana-indicators.
'';
};
};
@ -39,16 +40,36 @@ in
# libayatana-common's ayatana-indicators.target with explicit Wants & Before to bring up requested indicator services
systemd.user.targets =
let
indicatorServices = lib.lists.flatten (
map (pkg: (map (ind: "${ind}.service") pkg.passthru.ayatana-indicators)) cfg.packages
);
namesToServices = map (indicator: "${indicator}.service");
indicatorServices =
target:
lib.lists.flatten (
map (
pkg:
if lib.isList pkg.passthru.ayatana-indicators then
# Old format, add to every target
(lib.warn "${pkg.name} is using the old passthru.ayatana-indicators format, please update it!" (
namesToServices pkg.passthru.ayatana-indicators
))
else
# New format, filter by target being mentioned
(namesToServices (
builtins.filter (
service:
builtins.any (
targetPrefix: "${targetPrefix}-indicators" == target
) pkg.passthru.ayatana-indicators.${service}
) (builtins.attrNames pkg.passthru.ayatana-indicators)
))
) cfg.packages
);
in
lib.attrsets.mapAttrs
(_: desc: {
(name: desc: {
description = "Target representing the lifecycle of the ${desc}. Each indicator should be bound to it in its individual service file";
partOf = [ "graphical-session.target" ];
wants = indicatorServices;
before = indicatorServices;
wants = indicatorServices name;
before = indicatorServices name;
})
{
ayatana-indicators = "Ayatana Indicators";