about summary refs log tree commit diff
path: root/nixos/modules/services/desktops/ayatana-indicators.nix
blob: 613a2f03ea054206de0c4ee197caa527ebf7e371 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{ config
, pkgs
, lib
, ...
}:

let
  cfg = config.services.ayatana-indicators;
in
{
  options.services.ayatana-indicators = {
    enable = lib.mkEnableOption ''
      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 = ''
        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 ];
}