nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
7.11k stars 1.83k forks source link

bug: desktop-specific gui targets should not bind directly to graphical-session.target #2505

Closed dmayle closed 2 years ago

dmayle commented 2 years ago

Is there an existing issue for this?

Issue description

In the world of systemd X/Wayland session management, there exists a graphical-session.target which is a unit started with each (and every) X or Wayland session. This target groups desktop sessions (loose connection) like sway or gnome, and is bound to units (hard connection) which should start in all desktop sessions.

When choosing systemd integration with home manager, sway/wayland-specific packages like waybar and wlsunset are connected in such a way that if graphical-session.target is started they will be started as well. This breaks the use of more than one session type via the displaymanager, as loading an X-based session can load wayland units, or choosing gnome can load sway units.

Services that support both X and Wayland, and are requested by the user (e.g. flameshot) can be bound to graphical-session.target, but programs like waybar should be bound to sway-session.target

desktop sessions like sway-session.target should "Requires" graphical-session.target, rather than being "BindsTo", and the session commands should start sway-session.target directly (as it does in sway.nix)

Maintainer CC

@berbiche For waybar.nix @alexarice @sumnerevans for sway.nix

System information

N/A
dmayle commented 2 years ago

I created this because of sway programs breaking my gnome session, but upon re-reading the doc, it's not clear I have this right. I originally thought that BindsTo was bi-directional, but now I'm not sure. It is possible that it was broken because of improper cleanup. I'm closing this, and will reopen it if I can verify that the BindsTo relationship is bi-directional

berbiche commented 2 years ago

For Waybar, I will add an option to change the systemd target that starts the program (the Install.WantedBy setting).

I thought the option was already there but I had been using mkForce to override it.

dmayle commented 2 years ago

After further research, the "correct" usage is documented in the systemd.special(7) man page. A specific session (e.g. sway-session.target) should BindTo graphical-session.target, and services that are part of that session (e.g. waybar) should be PartOf graphical-session.target, but WantedBy the specific session like sway-session.target.

dmayle commented 2 years ago

To finish up my side of this, I mentioned that sway programs were breaking my gnome-session, and it turns out that starting wob (using tail from a fifo) from sway config prevented gdm from cleaning up the session. I've moved wob over to systemd, and combined with these changes, my sway session works as it should