at master 2.8 kB view raw
1{ 2 config, 3 pkgs, 4 lib, 5 ... 6}: 7 8let 9 cfg = config.services.ayatana-indicators; 10in 11{ 12 options.services.ayatana-indicators = { 13 enable = lib.mkEnableOption '' 14 Ayatana Indicators, a continuation of Canonical's Application Indicators 15 ''; 16 17 packages = lib.mkOption { 18 type = lib.types.listOf lib.types.package; 19 default = [ ]; 20 example = lib.literalExpression "with pkgs; [ ayatana-indicator-messages ]"; 21 description = '' 22 List of packages containing Ayatana Indicator services 23 that should be brought up by a SystemD "ayatana-indicators" user target. 24 25 Packages specified here must have passthru.ayatana-indicators set correctly. 26 27 If, how, and where these indicators are displayed will depend on your DE. 28 Which target they will be brought up by depends on the packages' passthru.ayatana-indicators. 29 ''; 30 }; 31 }; 32 33 config = lib.mkIf cfg.enable { 34 environment = { 35 systemPackages = cfg.packages; 36 37 pathsToLink = [ "/share/ayatana" ]; 38 }; 39 40 # libayatana-common's ayatana-indicators.target with explicit Wants & Before to bring up requested indicator services 41 systemd.user.targets = 42 let 43 namesToServices = map (indicator: "${indicator}.service"); 44 indicatorServices = 45 target: 46 lib.lists.flatten ( 47 map ( 48 pkg: 49 if lib.isList pkg.passthru.ayatana-indicators then 50 # Old format, add to every target 51 (lib.warn "${pkg.name} is using the old passthru.ayatana-indicators format, please update it!" ( 52 namesToServices pkg.passthru.ayatana-indicators 53 )) 54 else 55 # New format, filter by target being mentioned 56 (namesToServices ( 57 builtins.filter ( 58 service: 59 builtins.any ( 60 targetPrefix: "${targetPrefix}-indicators" == target 61 ) pkg.passthru.ayatana-indicators.${service} 62 ) (builtins.attrNames pkg.passthru.ayatana-indicators) 63 )) 64 ) cfg.packages 65 ); 66 in 67 lib.attrsets.mapAttrs 68 (name: desc: { 69 description = "Target representing the lifecycle of the ${desc}. Each indicator should be bound to it in its individual service file"; 70 partOf = [ "graphical-session.target" ]; 71 wants = indicatorServices name; 72 before = indicatorServices name; 73 }) 74 { 75 ayatana-indicators = "Ayatana Indicators"; 76 lomiri-indicators = "Ayatana/Lomiri Indicators that shall be run in Lomiri"; 77 }; 78 }; 79 80 meta.maintainers = with lib.maintainers; [ OPNA2608 ]; 81}