From f15b151ca1c4aea23515c241051d71f1b5cf97c8 Mon Sep 17 00:00:00 2001 From: Nicolas Berbiche Date: Thu, 23 Dec 2021 17:00:31 -0500 Subject: [PATCH] waybar: configurable systemd WantedBy target (#2524) Before this commit, a user needed to override the systemd target that would start Waybar with `mkForce`, this is no longer necessary. --- modules/programs/waybar.nix | 16 +++++++++++++++- .../systemd-with-graphical-session-target.nix | 1 + ...systemd-with-graphical-session-target.service | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) 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