From 8587c2ff0ea82a93a265dbcbad7df88c80de1b9c Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Tue, 31 Dec 2024 10:00:57 +0000 Subject: [PATCH] waybar: use config.wayland.systemd.target Also add `ConditionEnvironment`. --- modules/programs/waybar.nix | 8 +++++--- .../modules/programs/waybar/deprecated-modules-option.nix | 4 +--- tests/modules/programs/waybar/settings-complex.nix | 4 +--- tests/modules/programs/waybar/settings-with-attrs.nix | 2 -- tests/modules/programs/waybar/styling.nix | 4 +--- .../waybar/systemd-with-graphical-session-target.nix | 4 +--- .../waybar/systemd-with-graphical-session-target.service | 5 +++-- 7 files changed, 12 insertions(+), 19 deletions(-) diff --git a/modules/programs/waybar.nix b/modules/programs/waybar.nix index 8150223c..dbbe89c3 100644 --- a/modules/programs/waybar.nix +++ b/modules/programs/waybar.nix @@ -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) diff --git a/tests/modules/programs/waybar/deprecated-modules-option.nix b/tests/modules/programs/waybar/deprecated-modules-option.nix index 09f163b0..2c677aac 100644 --- a/tests/modules/programs/waybar/deprecated-modules-option.nix +++ b/tests/modules/programs/waybar/deprecated-modules-option.nix @@ -1,6 +1,4 @@ -{ config, lib, pkgs, ... }: - -with lib; +{ config, ... }: { config = { diff --git a/tests/modules/programs/waybar/settings-complex.nix b/tests/modules/programs/waybar/settings-complex.nix index 2e205a7d..a5413193 100644 --- a/tests/modules/programs/waybar/settings-complex.nix +++ b/tests/modules/programs/waybar/settings-complex.nix @@ -1,6 +1,4 @@ -{ config, lib, pkgs, ... }: - -with lib; +{ config, ... }: { config = { diff --git a/tests/modules/programs/waybar/settings-with-attrs.nix b/tests/modules/programs/waybar/settings-with-attrs.nix index ac7e20fa..992e42c6 100644 --- a/tests/modules/programs/waybar/settings-with-attrs.nix +++ b/tests/modules/programs/waybar/settings-with-attrs.nix @@ -1,7 +1,5 @@ { config, lib, pkgs, ... }: -with lib; - { config = { home.stateVersion = "21.11"; diff --git a/tests/modules/programs/waybar/styling.nix b/tests/modules/programs/waybar/styling.nix index 1952c4fb..0025acd5 100644 --- a/tests/modules/programs/waybar/styling.nix +++ b/tests/modules/programs/waybar/styling.nix @@ -1,6 +1,4 @@ -{ config, lib, pkgs, ... }: - -with lib; +{ config, ... }: { config = { 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 dc7a620f..e9694e53 100644 --- a/tests/modules/programs/waybar/systemd-with-graphical-session-target.nix +++ b/tests/modules/programs/waybar/systemd-with-graphical-session-target.nix @@ -1,6 +1,4 @@ -{ config, lib, pkgs, ... }: - -with lib; +{ config, ... }: { config = { 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 c99c8c13..f3e3b24a 100644 --- a/tests/modules/programs/waybar/systemd-with-graphical-session-target.service +++ b/tests/modules/programs/waybar/systemd-with-graphical-session-target.service @@ -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