diff --git a/modules/services/imapnotify.nix b/modules/services/imapnotify.nix
index 048e80974045..bc595ca9549b 100644
--- a/modules/services/imapnotify.nix
+++ b/modules/services/imapnotify.nix
@@ -21,10 +21,9 @@ let
Unit = { Description = "imapnotify for ${name}"; };
Service = {
+ # Use the nix store path for config to ensure service restarts when it changes
ExecStart =
- "${getExe cfg.package} -conf '${config.xdg.configHome}/imapnotify/${
- configName account
- }'";
+ "${getExe cfg.package} -conf '${genAccountConfig account}'";
Restart = "always";
RestartSec = 30;
Type = "simple";
@@ -44,11 +43,9 @@ let
value = {
enable = true;
config = {
- ProgramArguments = [
- "${getExe cfg.package}"
- "-conf"
- "${config.xdg.configHome}/imapnotify/${configName account}"
- ];
+ # Use the nix store path for config to ensure service restarts when it changes
+ ProgramArguments =
+ [ "${getExe cfg.package}" "-conf" "${genAccountConfig account}" ];
KeepAlive = true;
ThrottleInterval = 30;
ExitTimeOut = 0;
diff --git a/tests/default.nix b/tests/default.nix
index 2fe309895d0f..890264030354 100644
--- a/tests/default.nix
+++ b/tests/default.nix
@@ -146,8 +146,8 @@ import nmt {
./modules/xresources
] ++ lib.optionals isDarwin [
./modules/launchd
+ ./modules/services/imapnotify-darwin
./modules/targets-darwin
- ./modules/programs/goimapnotify
] ++ lib.optionals isLinux [
./modules/config/i18n
./modules/i18n/input-method
@@ -205,6 +205,7 @@ import nmt {
./modules/services/gpg-agent
./modules/services/gromit-mpx
./modules/services/home-manager-auto-upgrade
+ ./modules/services/imapnotify
./modules/services/kanshi
./modules/services/lieer
./modules/services/mopidy
diff --git a/tests/modules/programs/goimapnotify/default.nix b/tests/modules/programs/goimapnotify/default.nix
deleted file mode 100644
index a2adc553d44e..000000000000
--- a/tests/modules/programs/goimapnotify/default.nix
+++ /dev/null
@@ -1 +0,0 @@
-{ goimapnotify-launchd = ./launchd.nix; }
diff --git a/tests/modules/services/imapnotify-darwin/default.nix b/tests/modules/services/imapnotify-darwin/default.nix
new file mode 100644
index 000000000000..a722604d7b37
--- /dev/null
+++ b/tests/modules/services/imapnotify-darwin/default.nix
@@ -0,0 +1 @@
+{ imapnotify-launchd = ./launchd.nix; }
diff --git a/tests/modules/programs/goimapnotify/launchd.nix b/tests/modules/services/imapnotify-darwin/launchd.nix
similarity index 80%
rename from tests/modules/programs/goimapnotify/launchd.nix
rename to tests/modules/services/imapnotify-darwin/launchd.nix
index 3d4eca244138..5502ebbfc09f 100644
--- a/tests/modules/programs/goimapnotify/launchd.nix
+++ b/tests/modules/services/imapnotify-darwin/launchd.nix
@@ -33,8 +33,9 @@ with lib;
nmt.script = let
serviceFileName = "org.nix-community.home.imapnotify-hm-example.com.plist";
in ''
- serviceFile=LaunchAgents/${serviceFileName}
+ serviceFile="LaunchAgents/${serviceFileName}"
+ serviceFileNormalized="$(normalizeStorePaths "$serviceFile")"
assertFileExists $serviceFile
- assertFileContent $serviceFile ${./launchd.plist}
+ assertFileContent $serviceFileNormalized ${./launchd.plist}
'';
}
diff --git a/tests/modules/programs/goimapnotify/launchd.plist b/tests/modules/services/imapnotify-darwin/launchd.plist
similarity index 88%
rename from tests/modules/programs/goimapnotify/launchd.plist
rename to tests/modules/services/imapnotify-darwin/launchd.plist
index f8e45e8a32a1..75009bb6777d 100644
--- a/tests/modules/programs/goimapnotify/launchd.plist
+++ b/tests/modules/services/imapnotify-darwin/launchd.plist
@@ -19,7 +19,7 @@
@goimapnotify@/bin/goimapnotify
-conf
- /home/hm-user/.config/imapnotify/imapnotify-hm-example.com-config.json
+ /nix/store/00000000000000000000000000000000-imapnotify-hm-example.com-config.json
RunAtLoad
diff --git a/tests/modules/services/imapnotify/default.nix b/tests/modules/services/imapnotify/default.nix
new file mode 100644
index 000000000000..f3a725dd09f1
--- /dev/null
+++ b/tests/modules/services/imapnotify/default.nix
@@ -0,0 +1 @@
+{ imapnotify = ./imapnotify.nix; }
diff --git a/tests/modules/services/imapnotify/imapnotify.nix b/tests/modules/services/imapnotify/imapnotify.nix
new file mode 100644
index 000000000000..c607c042c2d6
--- /dev/null
+++ b/tests/modules/services/imapnotify/imapnotify.nix
@@ -0,0 +1,39 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+{
+ imports = [ ../../accounts/email-test-accounts.nix ];
+
+ accounts.email.accounts = {
+ "hm@example.com" = {
+ notmuch.enable = true;
+ imap.port = 993;
+
+ imapnotify = {
+ enable = true;
+ boxes = [ "Inbox" ];
+ onNotify = ''
+ ${pkgs.notmuch}/bin/notmuch new
+ '';
+ };
+ };
+ };
+
+ services.imapnotify = {
+ enable = true;
+ package = (config.lib.test.mkStubPackage {
+ name = "goimapnotify";
+ outPath = "@goimapnotify@";
+ });
+ };
+
+ test.stubs.notmuch = { };
+
+ nmt.script = ''
+ serviceFile="home-files/.config/systemd/user/imapnotify-hm-example.com.service"
+ serviceFileNormalized="$(normalizeStorePaths "$serviceFile")"
+ assertFileExists $serviceFile
+ assertFileContent $serviceFileNormalized ${./imapnotify.service}
+ '';
+}
diff --git a/tests/modules/services/imapnotify/imapnotify.service b/tests/modules/services/imapnotify/imapnotify.service
new file mode 100644
index 000000000000..3e3bd9ff60f2
--- /dev/null
+++ b/tests/modules/services/imapnotify/imapnotify.service
@@ -0,0 +1,12 @@
+[Install]
+WantedBy=default.target
+
+[Service]
+Environment=NOTMUCH_CONFIG=/home/hm-user/.config/notmuch/default/config
+ExecStart=@goimapnotify@/bin/goimapnotify -conf '/nix/store/00000000000000000000000000000000-imapnotify-hm-example.com-config.json'
+Restart=always
+RestartSec=30
+Type=simple
+
+[Unit]
+Description=imapnotify for hm-example.com