From 8cf61627a0b3fcd118f20aa2fd110bcd6dcb7b45 Mon Sep 17 00:00:00 2001 From: gmvar Date: Fri, 15 Nov 2024 09:34:24 -0800 Subject: [PATCH] hypridle: add `systemdTarget` option - added `systemdTarget` option - updated test to include new option - added documentation link to systemd service --- modules/services/hypridle.nix | 16 +++++++++++++++- .../services/hypridle/basic-configuration.nix | 8 ++++++++ ...systemd-with-graphical-session-target.service | 15 +++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/modules/services/hypridle/systemd-with-graphical-session-target.service diff --git a/modules/services/hypridle.nix b/modules/services/hypridle.nix index 0e28c5438..b0b7aeeeb 100644 --- a/modules/services/hypridle.nix +++ b/modules/services/hypridle.nix @@ -63,6 +63,19 @@ in { List of prefix of attributes to source at the top of the config. ''; }; + + systemdTarget = lib.mkOption { + type = lib.types.str; + default = "graphical-session.target"; + example = "hyprland-session.target"; + description = '' + The systemd target that will automatically start the hypridle service. + + When setting this value to `"hyprland-session.target"`, + make sure to also enable {option}`wayland.windowManager.hyprland.systemd.enable`, + otherwise the service may never be started. + ''; + }; }; config = mkIf cfg.enable { @@ -74,11 +87,12 @@ in { }; systemd.user.services.hypridle = { - Install = { WantedBy = [ "graphical-session.target" ]; }; + Install = { WantedBy = [ cfg.systemdTarget ]; }; Unit = { ConditionEnvironment = "WAYLAND_DISPLAY"; Description = "hypridle"; + Documentation = "https://wiki.hyprland.org/Hypr-Ecosystem/hypridle/"; After = [ "graphical-session-pre.target" ]; PartOf = [ "graphical-session.target" ]; X-Restart-Triggers = diff --git a/tests/modules/services/hypridle/basic-configuration.nix b/tests/modules/services/hypridle/basic-configuration.nix index 461f70a51..3db636542 100644 --- a/tests/modules/services/hypridle/basic-configuration.nix +++ b/tests/modules/services/hypridle/basic-configuration.nix @@ -24,6 +24,8 @@ } ]; }; + + systemdTarget = "hyprland-session.target"; }; test.stubs.hypridle = { }; @@ -34,5 +36,11 @@ assertFileExists $config assertFileExists $clientServiceFile assertFileContent $config ${./hypridle.conf} + + serviceFile=$(normalizeStorePaths $clientServiceFile) + assertFileContent "$serviceFile" ${ + ./systemd-with-graphical-session-target.service + } + ''; } diff --git a/tests/modules/services/hypridle/systemd-with-graphical-session-target.service b/tests/modules/services/hypridle/systemd-with-graphical-session-target.service new file mode 100644 index 000000000..40bbd6244 --- /dev/null +++ b/tests/modules/services/hypridle/systemd-with-graphical-session-target.service @@ -0,0 +1,15 @@ +[Install] +WantedBy=hyprland-session.target + +[Service] +ExecStart=@hypridle@/bin/dummy +Restart=always +RestartSec=10 + +[Unit] +After=graphical-session-pre.target +ConditionEnvironment=WAYLAND_DISPLAY +Description=hypridle +Documentation=https://wiki.hyprland.org/Hypr-Ecosystem/hypridle/ +PartOf=graphical-session.target +X-Restart-Triggers=/nix/store/00000000000000000000000000000000-hm_hyprhypridle.conf