From 2777de38dd20826238712c8fdaac3e960773e43a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Zavala=20Villag=C3=B3mez?= Date: Sun, 24 Nov 2024 08:05:10 -0500 Subject: [PATCH] hyprpaper: fix service when no config file The systemd user service depends on config.xdg.configFile."hypr/hyprpaper.conf".source for `X-Restart-Triggers`. When `cfg.settings` is the default `{}`, this causes failure since config.xdg.configFile."hypr/hyprpaper.conf".source will not exist. Making the addition conditional on `cfg.settings` actually having content, which would mean `xdg.configFile."hypr/hyprpaper.conf"` does exist, avoids the error. (cherry picked from commit bd58a1132e9b7f121f65313bc662ad6c8a05f878) --- modules/services/hyprpaper.nix | 2 +- tests/modules/services/hyprpaper/default.nix | 5 ++++- .../services/hyprpaper/no-configuration.nix | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 tests/modules/services/hyprpaper/no-configuration.nix diff --git a/modules/services/hyprpaper.nix b/modules/services/hyprpaper.nix index ede09b258..6c9ddb2cf 100644 --- a/modules/services/hyprpaper.nix +++ b/modules/services/hyprpaper.nix @@ -75,7 +75,7 @@ in { Description = "hyprpaper"; After = [ "graphical-session-pre.target" ]; PartOf = [ "graphical-session.target" ]; - X-Restart-Triggers = + X-Restart-Triggers = mkIf (cfg.settings != { }) [ "${config.xdg.configFile."hypr/hyprpaper.conf".source}" ]; }; diff --git a/tests/modules/services/hyprpaper/default.nix b/tests/modules/services/hyprpaper/default.nix index 2a5abbfed..d3e87df43 100644 --- a/tests/modules/services/hyprpaper/default.nix +++ b/tests/modules/services/hyprpaper/default.nix @@ -1 +1,4 @@ -{ hyprpaper-basic-configuration = ./basic-configuration.nix; } +{ + hyprpaper-basic-configuration = ./basic-configuration.nix; + hyprpaper-no-configuration = ./no-configuration.nix; +} diff --git a/tests/modules/services/hyprpaper/no-configuration.nix b/tests/modules/services/hyprpaper/no-configuration.nix new file mode 100644 index 000000000..15775e886 --- /dev/null +++ b/tests/modules/services/hyprpaper/no-configuration.nix @@ -0,0 +1,17 @@ +{ pkgs, ... }: + +{ + services.hyprpaper = { + enable = true; + settings = { }; + }; + + test.stubs.hyprpaper = { }; + + nmt.script = '' + config=home-files/.config/hypr/hyprpaper.conf + clientServiceFile=home-files/.config/systemd/user/hyprpaper.service + assertPathNotExists $config + assertFileExists $clientServiceFile + ''; +}