diff --git a/modules/services/imapnotify.nix b/modules/services/imapnotify.nix index 63e61e7c7..a52b86e97 100644 --- a/modules/services/imapnotify.nix +++ b/modules/services/imapnotify.nix @@ -27,8 +27,8 @@ let Restart = "always"; RestartSec = 30; Type = "simple"; - } // optionalAttrs account.notmuch.enable { - Environment = + Environment = [ "PATH=${cfg.path}" ] + ++ optional account.notmuch.enable "NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/default/config"; }; @@ -97,6 +97,17 @@ in { example = literalExpression "pkgs.imapnotify"; description = "The imapnotify package to use"; }; + + path = mkOption { + type = types.listOf types.package; + apply = lib.makeBinPath; + default = [ ]; + description = '' + List of packages to provide in PATH for the imapnotify service. + + Note, this does not apply to the Darwin launchd service. + ''; + }; }; accounts.email.accounts = mkOption { @@ -122,6 +133,12 @@ in { (checkAccounts (a: a.userName == null) "username") ]; + services.imapnotify.path = lib.mkMerge [ + (lib.mkIf config.programs.notmuch.enable [ pkgs.notmuch ]) + (lib.mkIf config.programs.mbsync.enable + [ config.programs.mbsync.package ]) + ]; + systemd.user.services = listToAttrs (map genAccountUnit imapnotifyAccounts); launchd.agents = listToAttrs (map genAccountAgent imapnotifyAccounts); diff --git a/tests/modules/services/imapnotify/imapnotify.service b/tests/modules/services/imapnotify/imapnotify.service index 3e3bd9ff6..cc1ba77b8 100644 --- a/tests/modules/services/imapnotify/imapnotify.service +++ b/tests/modules/services/imapnotify/imapnotify.service @@ -2,6 +2,7 @@ WantedBy=default.target [Service] +Environment=PATH= 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