nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
6.75k stars 1.77k forks source link

bug: msmtp: log files on `$HOME` #5831

Open octvs opened 1 week ago

octvs commented 1 week ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

I've started seeing $HOME/log $HOME/.msmtp.queue.log populated after using msmtp via neomutt. Although the latter is not, the former is a bit annoying. Home-manager already tries to avoids this 1, so I was curious to why this occured.

Interestingly this didn't happen until a month ago, so I've tried to git blame my way out of the problem both on my configuration and on upstream home-manager however I didn't find a fitting change on the suspected dates.

Home-manager uses2 msmtpq script3 to send emails through which manages also the queue of mails to be sent. As stated on upstream source of the script 4, it looks for MSMTPQ_Q and MSMTPQ_LOG variables to decide where to place these logs.

So such a patch fixes this problem for me:

diff --git a/modules/programs/msmtp.nix b/modules/programs/msmtp.nix
index 33973aff..4cd72a05 100644
--- a/modules/programs/msmtp.nix
+++ b/modules/programs/msmtp.nix
@@ -92,9 +92,11 @@ in {

     xdg.configFile."msmtp/config".text = configFile msmtpAccounts;

-    home.sessionVariables = {
+    home.sessionVariables = rec {
       MSMTP_QUEUE = "${config.xdg.dataHome}/msmtp/queue";
+      MSMTPQ_Q = MSMTP_QUEUE;
       MSMTP_LOG = "${config.xdg.dataHome}/msmtp/queue.log";
+      MSMTPQ_LOG = MSMTPQ_LOG;
     };
   };
 }

However I'm still not convinced why the problem started occuring at a certain point in time.

This is somewhat related to #2933, although narrower in scope.

Maintainer CC

No response

System information

- system: `"x86_64-linux"`
 - host os: `Linux 5.15.146.1-microsoft-standard-WSL2, Arch Linux, noversion, rolling`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.20.5`
 - nixpkgs: `not found`
octvs commented 1 week ago

Looking through this again, msmtp docs doesn't even consist env vars MSMTP_QUEUE and MSMTP_LOG 1, cloning the upstream repo 2 and greping through also yields no results. Maybe these could be removed?