treewide: standardize wayland graphical services

PR #6253
This commit is contained in:
Robert Helgesson 2025-01-03 18:25:06 +01:00
commit ef64efdbac
Failed to generate hash of commit
24 changed files with 80 additions and 52 deletions

View file

@ -417,6 +417,7 @@ let
./systemd.nix
./targets/darwin
./targets/generic-linux.nix
./wayland.nix
./xresources.nix
./xsession.nix
./misc/nix.nix

View file

@ -199,7 +199,8 @@ in {
systemd.target = mkOption {
type = str;
default = "graphical-session.target";
default = config.wayland.systemd.target;
defaultText = literalExpression "config.wayland.systemd.target";
example = "sway-session.target";
description = ''
The systemd target that will automatically start the Waybar service.
@ -309,8 +310,9 @@ in {
Description =
"Highly customizable Wayland bar for Sway and Wlroots based compositors.";
Documentation = "https://github.com/Alexays/Waybar/wiki";
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session-pre.target" ];
PartOf = [ cfg.systemd.target ];
After = [ cfg.systemd.target ];
ConditionEnvironment = "WAYLAND_DISPLAY";
X-Restart-Triggers = optional (settings != [ ])
"${config.xdg.configFile."waybar/config".source}"
++ optional (cfg.style != null)

View file

@ -57,8 +57,8 @@ in {
services.avizo = {
Unit = {
Description = "Volume/backlight OSD indicator";
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
PartOf = [ config.wayland.systemd.target ];
After = [ config.wayland.systemd.target ];
ConditionEnvironment = "WAYLAND_DISPLAY";
Documentation = "man:avizo(1)";
};
@ -69,7 +69,7 @@ in {
Restart = "always";
};
Install = { WantedBy = [ "graphical-session.target" ]; };
Install = { WantedBy = [ config.wayland.systemd.target ]; };
};
};
};

View file

@ -11,7 +11,8 @@ in {
systemdTarget = mkOption {
type = types.str;
default = "graphical-session.target";
default = config.wayland.systemd.target;
defaultText = literalExpression "config.wayland.systemd.target";
example = "sway-session.target";
description = ''
The systemd target that will automatically start the clipman service.
@ -34,8 +35,9 @@ in {
systemd.user.services.clipman = {
Unit = {
Description = "Clipboard management daemon";
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
PartOf = [ cfg.systemdTarget ];
After = [ cfg.systemdTarget ];
ConditionEnvironment = "WAYLAND_DISPLAY";
};
Service = {

View file

@ -180,8 +180,8 @@ in {
systemd.user.services.dunst = {
Unit = {
Description = "Dunst notification daemon";
After = [ "graphical-session-pre.target" ];
PartOf = [ "graphical-session.target" ];
After = [ config.wayland.systemd.target ];
PartOf = [ config.wayland.systemd.target ];
};
Service = {

View file

@ -88,8 +88,9 @@ in {
Unit = {
Description = "Fnott notification daemon";
Documentation = "man:fnott(1)";
After = [ "graphical-session-pre.target" ];
PartOf = [ "graphical-session.target" ];
After = [ config.wayland.systemd.target ];
PartOf = [ config.wayland.systemd.target ];
ConditionEnvironment = "WAYLAND_DISPLAY";
};
Service = {

View file

@ -74,13 +74,13 @@ in {
};
systemd.user.services.hypridle = {
Install = { WantedBy = [ "graphical-session.target" ]; };
Install = { WantedBy = [ config.wayland.systemd.target ]; };
Unit = {
ConditionEnvironment = "WAYLAND_DISPLAY";
Description = "hypridle";
After = [ "graphical-session-pre.target" ];
PartOf = [ "graphical-session.target" ];
After = [ config.wayland.systemd.target ];
PartOf = [ config.wayland.systemd.target ];
X-Restart-Triggers = mkIf (cfg.settings != { })
[ "${config.xdg.configFile."hypr/hypridle.conf".source}" ];
};

View file

@ -68,13 +68,13 @@ in {
};
systemd.user.services.hyprpaper = {
Install = { WantedBy = [ "graphical-session.target" ]; };
Install = { WantedBy = [ config.wayland.systemd.target ]; };
Unit = {
ConditionEnvironment = "WAYLAND_DISPLAY";
Description = "hyprpaper";
After = [ "graphical-session-pre.target" ];
PartOf = [ "graphical-session.target" ];
After = [ config.wayland.systemd.target ];
PartOf = [ config.wayland.systemd.target ];
X-Restart-Triggers = mkIf (cfg.settings != { })
[ "${config.xdg.configFile."hypr/hyprpaper.conf".source}" ];
};

View file

@ -286,7 +286,8 @@ in {
systemdTarget = mkOption {
type = types.str;
default = "sway-session.target";
default = config.wayland.systemd.target;
defaultText = literalExpression "config.wayland.systemd.target";
description = ''
Systemd target to bind to.
'';
@ -342,6 +343,7 @@ in {
Unit = {
Description = "Dynamic output configuration";
Documentation = "man:kanshi(1)";
ConditionEnvironment = "WAYLAND_DISPLAY";
PartOf = cfg.systemdTarget;
Requires = cfg.systemdTarget;
After = cfg.systemdTarget;

View file

@ -88,7 +88,8 @@ in {
systemdTarget = mkOption {
type = types.str;
default = "graphical-session.target";
default = config.wayland.systemd.target;
defaultText = literalExpression "config.wayland.systemd.target";
example = "sway-session.target";
description = ''
Systemd target to bind to.
@ -107,7 +108,8 @@ in {
Description = "Idle manager for Wayland";
Documentation = "man:swayidle(1)";
ConditionEnvironment = "WAYLAND_DISPLAY";
PartOf = [ "graphical-session.target" ];
PartOf = [ cfg.systemdTarget ];
After = [ cfg.systemdTarget ];
};
Service = {

View file

@ -95,8 +95,8 @@ in {
Unit = {
Description = "Swaync notification daemon";
Documentation = "https://github.com/ErikReider/SwayNotificationCenter";
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session-pre.target" ];
PartOf = [ config.wayland.systemd.target ];
After = [ config.wayland.systemd.target ];
ConditionEnvironment = "WAYLAND_DISPLAY";
};
@ -107,7 +107,7 @@ in {
Restart = "on-failure";
};
Install.WantedBy = [ "graphical-session.target" ];
Install.WantedBy = [ config.wayland.systemd.target ];
};
};
}

View file

@ -56,8 +56,8 @@ in {
services.swayosd = {
Unit = {
Description = "Volume/backlight OSD indicator";
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
PartOf = [ config.wayland.systemd.target ];
After = [ config.wayland.systemd.target ];
ConditionEnvironment = "WAYLAND_DISPLAY";
Documentation = "man:swayosd(1)";
StartLimitBurst = 5;
@ -76,7 +76,7 @@ in {
RestartSec = "2s";
};
Install = { WantedBy = [ "graphical-session.target" ]; };
Install = { WantedBy = [ config.wayland.systemd.target ]; };
};
};
};

View file

@ -50,8 +50,8 @@ in {
Description =
"A lightweight overlay volume/backlight/progress/anything bar for Wayland";
Documentation = "man:wob(1)";
PartOf = "graphical-session.target";
After = "graphical-session.target";
PartOf = [ config.wayland.systemd.target ];
After = [ config.wayland.systemd.target ];
ConditionEnvironment = "WAYLAND_DISPLAY";
};
Service = {
@ -59,7 +59,7 @@ in {
ExecStart = builtins.concatStringsSep " " ([ (getExe cfg.package) ]
++ optional (cfg.settings != { }) "--config ${configFile}");
};
Install.WantedBy = [ "graphical-session.target" ];
Install.WantedBy = [ config.wayland.systemd.target ];
};
sockets.wob = {

24
modules/wayland.nix Normal file
View file

@ -0,0 +1,24 @@
{ lib, ... }:
{
meta.maintainers = [ lib.maintainers.thiagokokada ];
options = {
wayland = {
systemd.target = lib.mkOption {
type = lib.types.str;
default = "graphical-session.target";
example = "sway-session.target";
description = ''
The systemd target that will automatically start the graphical Wayland services.
This option is a generalization of individual `systemd.target` or `systemdTarget`,
and affect all Wayland services by default.
When setting this value to `"sway-session.target"`,
make sure to also enable {option}`wayland.windowManager.sway.systemd.enable`,
otherwise the service may never be started.
'';
};
};
};
}

View file

@ -1,6 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{ config, ... }:
{
config = {

View file

@ -1,6 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{ config, ... }:
{
config = {

View file

@ -1,7 +1,5 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
home.stateVersion = "21.11";

View file

@ -1,6 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{ config, ... }:
{
config = {

View file

@ -1,6 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{ config, ... }:
{
config = {

View file

@ -8,7 +8,8 @@ KillMode=mixed
Restart=on-failure
[Unit]
After=graphical-session-pre.target
After=sway-session.target
ConditionEnvironment=WAYLAND_DISPLAY
Description=Highly customizable Wayland bar for Sway and Wlroots based compositors.
Documentation=https://github.com/Alexays/Waybar/wiki
PartOf=graphical-session.target
PartOf=sway-session.target

View file

@ -8,6 +8,7 @@ KillMode=mixed
Restart=on-failure
[Unit]
After=graphical-session.target
After=sway-session.target
ConditionEnvironment=WAYLAND_DISPLAY
Description=Clipboard management daemon
PartOf=graphical-session.target
PartOf=sway-session.target

View file

@ -4,7 +4,8 @@ ExecStart=@fnott@/bin/fnott -c /home/hm-user/.config/fnott/fnott.ini
Type=dbus
[Unit]
After=graphical-session-pre.target
After=graphical-session.target
ConditionEnvironment=WAYLAND_DISPLAY
Description=Fnott notification daemon
Documentation=man:fnott(1)
PartOf=graphical-session.target

View file

@ -1,4 +1,4 @@
{ config, pkgs, lib, ... }:
{ config, ... }:
{
services.swayidle = {
@ -50,6 +50,7 @@
Type=simple
[Unit]
After=graphical-session.target
ConditionEnvironment=WAYLAND_DISPLAY
Description=Idle manager for Wayland
Documentation=man:swayidle(1)

View file

@ -24,7 +24,7 @@
Type=dbus
[Unit]
After=graphical-session-pre.target
After=graphical-session.target
ConditionEnvironment=WAYLAND_DISPLAY
Description=Swaync notification daemon
Documentation=https://github.com/ErikReider/SwayNotificationCenter