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

Changed files
+28 -7
nixos
modules
services
+28 -7
nixos/modules/services/desktops/ayatana-indicators.nix
···
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.
'';
};
};
···
# 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";