Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions modules/services/imapnotify.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion tests/modules/programs/goimapnotify/default.nix

This file was deleted.

1 change: 1 addition & 0 deletions tests/modules/services/imapnotify-darwin/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ imapnotify-launchd = ./launchd.nix; }
Original file line number Diff line number Diff line change
Expand Up @@ -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}
'';
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<array>
<string>@goimapnotify@/bin/goimapnotify</string>
<string>-conf</string>
<string>/home/hm-user/.config/imapnotify/imapnotify-hm-example.com-config.json</string>
<string>/nix/store/00000000000000000000000000000000-imapnotify-hm-example.com-config.json</string>
</array>
<key>RunAtLoad</key>
<true/>
Expand Down
1 change: 1 addition & 0 deletions tests/modules/services/imapnotify/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ imapnotify = ./imapnotify.nix; }
39 changes: 39 additions & 0 deletions tests/modules/services/imapnotify/imapnotify.nix
Original file line number Diff line number Diff line change
@@ -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}
'';
}
12 changes: 12 additions & 0 deletions tests/modules/services/imapnotify/imapnotify.service
Original file line number Diff line number Diff line change
@@ -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