2024-08-15 23:06:15 +03:00
{ pkgs , lib , . . . }:
let
2023-10-20 12:50:27 +03:00
user = " a l i c e " ;
2024-08-15 23:06:15 +03:00
in
{
2023-10-20 12:50:27 +03:00
name = " a y a t a n a - i n d i c a t o r s " ;
meta = {
2024-01-02 20:33:16 +03:00
maintainers = lib . teams . lomiri . members ;
2023-10-20 12:50:27 +03:00
} ;
2024-08-15 23:06:15 +03:00
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 ;
} ;
services . displayManager . defaultSession = lib . mkForce " m a t e " ;
services . ayatana-indicators = {
enable = true ;
packages =
with pkgs ;
[
ayatana-indicator-datetime
ayatana-indicator-display
ayatana-indicator-messages
ayatana-indicator-power
ayatana-indicator-session
ayatana-indicator-sound
]
++ ( with pkgs . lomiri ; [
lomiri-indicator-network
telephony-service
] ) ;
} ;
# Setup needed by some indicators
services . accounts-daemon . enable = true ; # messages
hardware . pulseaudio . enable = true ; # sound
# Lomiri-ish setup for Lomiri indicators
# TODO move into a Lomiri module, once the package set is far enough for the DE to start
networking . networkmanager . enable = true ; # lomiri-network-indicator
# TODO potentially urfkill for lomiri-network-indicator?
services . dbus . packages = with pkgs . lomiri ; [ libusermetrics ] ;
environment . systemPackages = with pkgs . lomiri ; [ lomiri-schemas ] ;
services . telepathy . enable = true ;
users . users . usermetrics = {
group = " u s e r m e t r i c s " ;
home = " / v a r / l i b / u s e r m e t r i c s " ;
createHome = true ;
isSystemUser = true ;
} ;
users . groups . usermetrics = { } ;
2024-01-21 01:03:40 +03:00
} ;
2023-10-20 12:50:27 +03:00
# 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?
2024-08-15 23:06:15 +03:00
testScript =
{ nodes , . . . }:
let
runCommandOverServiceList = list : command : lib . strings . concatMapStringsSep " \n " command list ;
2024-08-15 23:04:05 +03:00
runCommandOverAyatanaIndicators = runCommandOverServiceList
nodes . machine . systemd . user . targets . ayatana-indicators . wants ;
2024-08-15 23:06:15 +03:00
2024-08-15 22:21:44 +03:00
runCommandOverLomiriIndicators = runCommandOverServiceList nodes . machine . systemd . user . targets . lomiri-indicators . wants ;
2024-08-15 23:06:15 +03:00
in
''
start_all ( )
machine . wait_for_x ( )
# Desktop environment should reach graphical-session.target
machine . wait_for_unit ( " g r a p h i c a l - s e s s i o n . t a r g e t " , " ${ 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
''
+ ( runCommandOverAyatanaIndicators (
service :
let
serviceExec = builtins . replaceStrings [ " . " ] [ " - " ] service ;
in
''
machine . wait_until_succeeds ( " p g r e p - u ${ user } - f ${ serviceExec } " )
machine . succeed ( " p k i l l - 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 ( " s t a r t a y a t a n a - i n d i c a t o r s . t a r g e t " , " ${ user } " )
machine . wait_for_unit ( " a y a t a n a - i n d i c a t o r s . t a r g e t " , " ${ 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
''
2024-08-15 22:21:44 +03:00
+ runCommandOverAyatanaIndicators ( service : ''
machine . wait_for_unit ( " ${ service } " , " ${ user } " )
'' )
+ ''
# Stop the target
machine . systemctl ( " s t o p a y a t a n a - i n d i c a t o r s . t a r g e t " , " ${ user } " )
# Let all indicator services do their shutdowns
# Not sure if there's a better way of awaiting this without false-positive potential
machine . sleep ( 10 )
# Lomiri uses a different target, which launches a slightly different set of indicators
machine . systemctl ( " s t a r t l o m i r i - i n d i c a t o r s . t a r g e t " , " ${ user } " )
machine . wait_for_unit ( " l o m i r i - i n d i c a t o r s . t a r g e t " , " ${ 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
''
+ runCommandOverLomiriIndicators ( service : ''
2024-08-15 23:06:15 +03:00
machine . wait_for_unit ( " ${ service } " , " ${ user } " )
'' ) ;
}