From 5e2f47c5a52707d250364401091e88021ba052a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Zavala=20Villag=C3=B3mez?= Date: Sat, 23 Nov 2024 16:16:15 -0500 Subject: [PATCH] hypridle: fix service when no config file The systemd user service depends on config.xdg.configFile."hypr/hypridle.conf".source for `X-Restart-Triggers`. When `cfg.settings` is the default `{}`, this causes failure since config.xdg.configFile."hypr/hypridle.conf".source will not exist. Making the addition conditional on `cfg.settings` actually having content, which would mean `xdg.configFile."hypr/hypridle.conf"` does exist, avoids the error. --- modules/services/hypridle.nix | 2 +- tests/modules/services/hypridle/default.nix | 5 ++++- .../modules/services/hypridle/no-configuration.nix | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 tests/modules/services/hypridle/no-configuration.nix diff --git a/modules/services/hypridle.nix b/modules/services/hypridle.nix index 0e28c5438..0d8a337b4 100644 --- a/modules/services/hypridle.nix +++ b/modules/services/hypridle.nix @@ -81,7 +81,7 @@ in { Description = "hypridle"; After = [ "graphical-session-pre.target" ]; PartOf = [ "graphical-session.target" ]; - X-Restart-Triggers = + X-Restart-Triggers = mkIf (cfg.settings != { }) [ "${config.xdg.configFile."hypr/hypridle.conf".source}" ]; }; diff --git a/tests/modules/services/hypridle/default.nix b/tests/modules/services/hypridle/default.nix index c959983c0..b351f1c00 100644 --- a/tests/modules/services/hypridle/default.nix +++ b/tests/modules/services/hypridle/default.nix @@ -1 +1,4 @@ -{ hypridle-basic-configuration = ./basic-configuration.nix; } +{ + hypridle-basic-configuration = ./basic-configuration.nix; + hypridle-no-configuration = ./no-configuration.nix; +} diff --git a/tests/modules/services/hypridle/no-configuration.nix b/tests/modules/services/hypridle/no-configuration.nix new file mode 100644 index 000000000..805e49561 --- /dev/null +++ b/tests/modules/services/hypridle/no-configuration.nix @@ -0,0 +1,14 @@ +{ pkgs, ... }: + +{ + services.hypridle.enable = true; + + test.stubs.hypridle = { }; + + nmt.script = '' + config=home-files/.config/hypr/hypridle.conf + clientServiceFile=home-files/.config/systemd/user/hypridle.service + assertPathNotExists $config + assertFileExists $clientServiceFile + ''; +}