Sway (via home-manager) startup and tray services

Hello. I’m on 23.11 NixOS + 23.11 home-manager and am trying to figure out how sway is supposed to be started along with various applets via systemd. Currently I start sway via the sway command and I have

wayland.windowManager.sway.systemd = true;
programs.waybar = {
  enable = true;
  systemd.enable = true;

and services like

  services = {
    blueman-applet.enable = true;

    fnott = {
      enable = true;
      settings = {
        main = {
          default-timeout = 10;

    network-manager-applet.enable = true;

    udiskie = {
      enable = true;
      automount = false;
      tray = "always";

However during the startup when sway startup script starts user’s sway-session.target and in turn user’s graphical-session.target many of those ‘tray’ services like e.g. blueman-applet applet fails completely while other seems to be running but have no tray icon or just doesn’t seem to function like fnott

Moreover even restarting them via systemctl --user restart doesn’t help unless I have home-manager.useUserPackages = true;

I’ve been trying to get what I’d say is a pretty normal/vanilla configuration functioning properly to no avail. Am I missing something obvious? I think the problem must be on my side because I don’t suppose 23.11 home-manager modules are this broken.

Can anybody advise? How do you configure and start sway (when going via home-manager route and not via system level NixOS modules)? Thanks.

1 Like

Running in to the same thing, it is because the systemd services such as waybar are bound to sway-session.target, meaning they start when it starts and stop when it stops. wayland.windowManager.sway.systemd = true; is what creates this target, which starts the sway-session.target when sway starts, so your waybar etc get started as expected.

The problem is that nixos/homemanager do not stop the sway-session.target when you exit sway, so many of those services will continue running thinking sway is still running, after you have quit sway. Some of them don’t care, others will crash due to the lack of a gui, and will crash repeatedly until systemd stops trying to restart them anymore. This is where you run into waybar not showing up again the second time you start sway.

I have tried all kinds of things to try and get that sway-session.target to stop when sway does and so far have found nothing that works. Seems to have very little interest from nixos/homemanager too. Every time I try to research this problem again I find new dead threads on the nixos forum asking about it with no reply.

some examples