diff --git a/modules/services/window-managers/hyprland.nix b/modules/services/window-managers/hyprland.nix index 73602ec61..a2775f526 100644 --- a/modules/services/window-managers/hyprland.nix +++ b/modules/services/window-managers/hyprland.nix @@ -277,12 +277,5 @@ in { [ "xdg-desktop-autostart.target" ]; }; }; - - systemd.user.targets.tray = { - Unit = { - Description = "Home Manager System Tray"; - Requires = [ "graphical-session-pre.target" ]; - }; - }; }; } diff --git a/modules/services/window-managers/i3-sway/sway.nix b/modules/services/window-managers/i3-sway/sway.nix index 4148fcf1d..36d27328e 100644 --- a/modules/services/window-managers/i3-sway/sway.nix +++ b/modules/services/window-managers/i3-sway/sway.nix @@ -553,13 +553,6 @@ in { optional cfg.systemd.xdgAutostart "xdg-desktop-autostart.target"; }; }; - - systemd.user.targets.tray = { - Unit = { - Description = "Home Manager System Tray"; - Requires = [ "graphical-session-pre.target" ]; - }; - }; } ]); } diff --git a/modules/services/window-managers/river.nix b/modules/services/window-managers/river.nix index 06d458411..cc10a4344 100644 --- a/modules/services/window-managers/river.nix +++ b/modules/services/window-managers/river.nix @@ -201,12 +201,5 @@ in { After = [ "graphical-session-pre.target" ]; }; }; - - systemd.user.targets.tray = { - Unit = { - Description = "Home Manager System Tray"; - Requires = [ "graphical-session-pre.target" ]; - }; - }; }; } diff --git a/modules/services/window-managers/wayfire.nix b/modules/services/window-managers/wayfire.nix index c551eb05f..e52201c79 100644 --- a/modules/services/window-managers/wayfire.nix +++ b/modules/services/window-managers/wayfire.nix @@ -189,12 +189,5 @@ After = [ "graphical-session-pre.target" ]; }; }; - - systemd.user.targets.tray = { - Unit = { - Description = "Home Manager System Tray"; - Requires = [ "graphical-session-pre.target" ]; - }; - }; }; } diff --git a/modules/wayland.nix b/modules/wayland.nix index 9a485c56c..6bf36162a 100644 --- a/modules/wayland.nix +++ b/modules/wayland.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ config, lib, ... }: { meta.maintainers = [ lib.maintainers.thiagokokada ]; @@ -21,4 +21,8 @@ }; }; }; + + config = lib.mkIf (!config.xsession.enable) { + systemd.user.targets.tray = config.xsession.trayTarget; + }; } diff --git a/modules/xsession.nix b/modules/xsession.nix index 269ce1fa0..edb99300e 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -13,6 +13,20 @@ in { xsession = { enable = mkEnableOption "X Session"; + trayTarget = mkOption { + readOnly = true; + internal = true; + visible = false; + description = "Common tray.target for both xsession and wayland"; + type = types.attrs; + default = { + Unit = { + Description = "Home Manager System Tray"; + Requires = [ "graphical-session-pre.target" ]; + }; + }; + }; + scriptPath = mkOption { type = types.str; default = ".xsession"; @@ -163,12 +177,7 @@ in { }; }; - tray = { - Unit = { - Description = "Home Manager System Tray"; - Requires = [ "graphical-session-pre.target" ]; - }; - }; + tray = cfg.trayTarget; }; };