diff --git a/modules/programs/waybar.nix b/modules/programs/waybar.nix index 1d76b5658..4c68e3f26 100644 --- a/modules/programs/waybar.nix +++ b/modules/programs/waybar.nix @@ -197,6 +197,20 @@ in { systemd.enable = mkEnableOption "Waybar systemd integration"; + systemd.target = mkOption { + type = str; + default = "graphical-session.target"; + example = "sway-session.target"; + description = '' + The systemd target that will automatically start the Waybar service. + + + When setting this value to "sway-session.target", + make sure to also enable , + otherwise the service may never be started. + ''; + }; + style = mkOption { type = nullOr (either path str); default = null; @@ -309,7 +323,7 @@ in { KillMode = "mixed"; }; - Install = { WantedBy = [ "graphical-session.target" ]; }; + Install = { WantedBy = [ cfg.systemd.target ]; }; }; }) ]); diff --git a/tests/modules/programs/waybar/systemd-with-graphical-session-target.nix b/tests/modules/programs/waybar/systemd-with-graphical-session-target.nix index a0a359d5f..624ab5039 100644 --- a/tests/modules/programs/waybar/systemd-with-graphical-session-target.nix +++ b/tests/modules/programs/waybar/systemd-with-graphical-session-target.nix @@ -10,6 +10,7 @@ with lib; package = config.lib.test.mkStubPackage { outPath = "@waybar@"; }; enable = true; systemd.enable = true; + systemd.target = "sway-session.target"; }; nmt.script = '' diff --git a/tests/modules/programs/waybar/systemd-with-graphical-session-target.service b/tests/modules/programs/waybar/systemd-with-graphical-session-target.service index e03326e6e..a954207d3 100644 --- a/tests/modules/programs/waybar/systemd-with-graphical-session-target.service +++ b/tests/modules/programs/waybar/systemd-with-graphical-session-target.service @@ -1,5 +1,5 @@ [Install] -WantedBy=graphical-session.target +WantedBy=sway-session.target [Service] ExecReload=kill -SIGUSR2 $MAINPID