summaryrefslogtreecommitdiff
path: root/modules/home/mu.nix
blob: c41070266240471e656d019489ac5e3ed101b568 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{ config, lib, pkgs, ...}: with lib; let
  cfg = config.santi-modules;
in {
  options.santi-modules.mu.enable = mkEnableOption "Enables mu, mbsync and msmtp";
  config = mkIf cfg.mu.enable {
    environment.systemPackages = [
      pkgs.parallel
    ];
    home-manager.users.leonardo = {
      programs = {
        mu.enable = true;
        msmtp.enable = true;
        mbsync.enable = true;
        offlineimap.enable = true;
      };
      services.mbsync = {
        enable = true;
        frequency = "*:0/5";
      };
      accounts.email.accounts = let
        gmailAccount = { email, secret, primary ? false } : {
          inherit primary;
          address = email;
          userName = email;
          realName = "Leonardo Ribeiro Santiago";
          imap.host = "imap.gmail.com";
          smtp.host = "smtp.gmail.com";
          msmtp.enable = true;
          mu.enable = true;
          mbsync = {
            enable = true;
            create = "both";
            expunge = "both";
          };
          passwordCommand = "cat ${secret.path}";
        };
      in with config.age.secrets; {
        personal = gmailAccount {
          email = "[email protected]";
          secret = personal-mail;
          primary = true;
        };
        university = gmailAccount {
          email = "[email protected]";
          secret = university-mail;
        };
        # supabase = gmailAccount {
        #   email = "[email protected]";
        #   secret = supabase-mail;
        # };
      };
    };
  };
}