Commit cb63d1292a02

Vincent Demeester <vincent@sbr.pm>
2019-03-23 10:17:05
profiles.mails: add frequency option…
… also, this is generated from https://sbr.pm/technical/mail-setup.html Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent bc9fde5
Changed files (1)
modules
profiles
modules/profiles/mails.nix
@@ -1,3 +1,5 @@
+# Generated from an org file 💃
+# See : https://sbr.pm/technical/mail-setup.html
 { config, lib, pkgs, ... }:
 
 with lib;
@@ -5,138 +7,151 @@ let
   cfg = config.profiles.mails;
 in
 {
-  options = {
-    profiles.mails = {
-      enable = mkOption {
-        default = false;
-        description = "Enable mails configurations";
-        type = types.bool;
-      };
+
+options = {
+  profiles.mails = {
+    enable = mkOption {
+      default = false;
+      description = "Enable mails configurations";
+      type = types.bool;
+    };
+    frequency = mkOption {
+      default = "*:0/30";
+      description = "Frequency at which the mail should be checked";
+      type = types.str;
     };
   };
-  config = mkIf cfg.enable {
-    accounts.email = {
-      maildirBasePath = "desktop/mails";
-      accounts = {
-        "redhat" = {
-          address = "vdemeest@redhat.com";
-          userName = "vdemeest@redhat.com";
-          realName = "Vincent Demeester";
-          passwordCommand = "${pkgs.gnupg}/bin/gpg -q --for-your-eyes-only --no-tty --exit-on-status-write-error --batch --passphrase-file ${config.home.homeDirectory}/sync/rh.pass -d ${config.home.homeDirectory}/desktop/documents/rh.pass.gpg";
-          imap.host = "imap.gmail.com";
-          smtp.host = "smtp.gmail.com";
-          mbsync = {
-            enable = true;
-            create = "both";
-            expunge = "both";
-            patterns = ["*" "![Gmail]*" "[Gmail]/Sent Mail" "[Gmail]/Starred" "[Gmail]/All Mail"];
-            extraConfig = {
-              channel = {
-                Sync = "All";
-              };
-            };
+};
+
+config = mkIf cfg.enable {
+
+accounts.email = {
+  maildirBasePath = "desktop/mails";
+  accounts = {
+    "redhat" = {
+      address = "vdemeest@redhat.com";
+      userName = "vdemeest@redhat.com";
+      realName = "Vincent Demeester";
+      passwordCommand = "${pkgs.gnupg}/bin/gpg -q --for-your-eyes-only --no-tty --exit-on-status-write-error --batch --passphrase-file ${config.home.homeDirectory}/sync/rh.pass -d ${config.home.homeDirectory}/desktop/documents/rh.pass.gpg";
+      imap.host = "imap.gmail.com";
+      smtp.host = "smtp.gmail.com";
+      mbsync = {
+        enable = true;
+        create = "both";
+        expunge = "both";
+        patterns = ["*" "![Gmail]*" "[Gmail]/Sent Mail" "[Gmail]/Starred" "[Gmail]/All Mail"];
+        extraConfig = {
+          channel = {
+            Sync = "All";
           };
-          notmuch.enable = true;
-          astroid.enable = true;
-          msmtp.enable = true;
-        };
-        "perso" = {
-          primary = true;
-          address = "vinc.demeester@gmail.com";
-          userName = "vinc.demeester@gmail.com";
-          realName = "Vincent Demeester";
-          passwordCommand = "${pkgs.gnupg}/bin/gpg -q --for-your-eyes-only --no-tty --exit-on-status-write-error --batch --passphrase-file ${config.home.homeDirectory}/sync/perso.pass -d ${config.home.homeDirectory}/desktop/documents/perso.pass.gpg";
-          imap.host = "imap.gmail.com";
-          smtp.host = "smtp.gmail.com";
-          mbsync = {
-            enable = true;
-            create = "both";
-            expunge = "both";
-            patterns = ["*" "![Gmail]*" "[Gmail]/Sent Mail" "[Gmail]/Starred" "[Gmail]/All Mail"];
-            extraConfig = {
-              channel = {
-                Sync = "All";
-              };
-            };
-          };
-          notmuch.enable = true;
-          astroid.enable = true;
-          msmtp.enable = true;
         };
       };
+      notmuch.enable = true;
+      astroid.enable = true;
+      msmtp.enable = true;
     };
-    services.mbsync = {
-      enable = true;
-      preExec = "${config.xdg.configHome}/mbsync/preExec";
-      postExec = "${config.xdg.configHome}/mbsync/postExec";
-      frequency = "*:0/30";
-    };
-    xdg.configFile."mbsync/preExec" = {
-      text = ''
-      #!${pkgs.stdenv.shell}
-
-      export NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/notmuchrc
-      export NMBGIT=${config.xdg.dataHome}/notmuch/nmbug
-      
-      ${pkgs.coreutils}/bin/mkdir -p ${config.home.homeDirectory}/desktop/mails/redhat ${config.home.homeDirectory}/desktop/mails/perso
-      ${pkgs.afew}/bin/afew -C  ${config.xdg.configHome}/notmuch/notmuchrc -m -v
-      '';
-      executable = true;
-    };
-    xdg.configFile."mbsync/postExec" = {
-      text = ''
-      #!${pkgs.stdenv.shell}
-
-      export NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/notmuchrc
-      export NMBGIT=${config.xdg.dataHome}/notmuch/nmbug
-
-      ${pkgs.notmuch}/bin/notmuch new
-      ${pkgs.afew}/bin/afew -C ${config.xdg.configHome}/notmuch/notmuchrc --tag --new -v
-      ${pkgs.notmuch}/bin/notmuch tag -inbox tag:inbox
-      #${pkgs.notmuch}/bin/notmuch tag -Inbox "NOT folder:Inbox and tag:Inbox"
-
-      ${pkgs.libnotify}/bin/notify-send "Mails synced 📫"
-      '';
-      executable = true;
-    };
-    programs.astroid = {
-      enable = true;
-      externalEditor = "emacsclient -c";
-      extraConfig = {
-        startup.queries.inbox = "tag:Inbox";
-        startup.queries.inbox_perso = "tag:Inbox and tag:perso";
-        startup.queries.inbox_redhat = "tag:Inbox and tag:redhat";
+    "perso" = {
+      primary = true;
+      address = "vinc.demeester@gmail.com";
+      userName = "vinc.demeester@gmail.com";
+      realName = "Vincent Demeester";
+      passwordCommand = "${pkgs.gnupg}/bin/gpg -q --for-your-eyes-only --no-tty --exit-on-status-write-error --batch --passphrase-file ${config.home.homeDirectory}/sync/perso.pass -d ${config.home.homeDirectory}/desktop/documents/perso.pass.gpg";
+      imap.host = "imap.gmail.com";
+      smtp.host = "smtp.gmail.com";
+      mbsync = {
+        enable = true;
+        create = "both";
+        expunge = "both";
+        patterns = ["*" "![Gmail]*" "[Gmail]/Sent Mail" "[Gmail]/Starred" "[Gmail]/All Mail"];
+        extraConfig = {
+          channel = {
+            Sync = "All";
+          };
+        };
       };
-    };
-    programs.mbsync.enable = true;
-    programs.afew = {
-      enable = true;
-      extraConfig = ''
-        [SpamFilter]
-        [KillThreadsFilter]
-        [ListMailsFilter]
-        [ArchiveSentMailsFilter]
-        [FolderNameFilter]
-        maildir_separator = /
-
-        [MailMover]
-        folders = perso/Inbox redhat/Inbox 
-        rename = true
-
-        perso/Inbox = 'NOT tag:Inbox':"perso/[Gmail]/All Mail"
-        redhat/Inbox = 'NOT tag:Inbox':"redhat/[Gmail]/All Mail"
-      '';
-    };
-    programs.notmuch.enable = true;
-    programs.msmtp.enable = true;
-    home.packages = with pkgs; [ mu ];
-    home.file."bin/msmtp" = {
-      text = ''
-      #!${pkgs.stdenv.shell}
-
-      ${pkgs.msmtp}/bin/msmtp --read-envelope-from $@
-      '';
-      executable = true;
+      notmuch.enable = true;
+      astroid.enable = true;
+      msmtp.enable = true;
     };
   };
+};
+
+services.mbsync = {
+  enable = true;
+  preExec = "${config.xdg.configHome}/mbsync/preExec";
+  postExec = "${config.xdg.configHome}/mbsync/postExec";
+  frequency = cfg.frequency;
+};
+
+xdg.configFile."mbsync/preExec" = {
+  text = ''
+  #!${pkgs.stdenv.shell}
+
+  export NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/notmuchrc
+  export NMBGIT=${config.xdg.dataHome}/notmuch/nmbug
+
+  ${pkgs.coreutils}/bin/mkdir -p ${config.home.homeDirectory}/desktop/mails/redhat ${config.home.homeDirectory}/desktop/mails/perso
+  ${pkgs.afew}/bin/afew -C  ${config.xdg.configHome}/notmuch/notmuchrc -m -v
+  '';
+  executable = true;
+};
+
+xdg.configFile."mbsync/postExec" = {
+  text = ''
+  #!${pkgs.stdenv.shell}
+
+  export NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/notmuchrc
+  export NMBGIT=${config.xdg.dataHome}/notmuch/nmbug
+
+  ${pkgs.notmuch}/bin/notmuch new
+  ${pkgs.afew}/bin/afew -C ${config.xdg.configHome}/notmuch/notmuchrc --tag --new -v
+  ${pkgs.notmuch}/bin/notmuch tag -inbox tag:inbox
+  #${pkgs.notmuch}/bin/notmuch tag -Inbox "NOT folder:Inbox and tag:Inbox"
+
+  ${pkgs.libnotify}/bin/notify-send "Mails synced 📫"
+  '';
+  executable = true;
+};
+
+programs.astroid = {
+  enable = true;
+  externalEditor = "emacsclient -c";
+  extraConfig = {
+    startup.queries.inbox = "tag:Inbox";
+    startup.queries.inbox_perso = "tag:Inbox and tag:perso";
+    startup.queries.inbox_redhat = "tag:Inbox and tag:redhat";
+  };
+};
+programs.mbsync.enable = true;
+programs.afew = {
+  enable = true;
+  extraConfig = ''
+    [SpamFilter]
+    [KillThreadsFilter]
+    [ListMailsFilter]
+    [ArchiveSentMailsFilter]
+    [FolderNameFilter]
+    maildir_separator = /
+
+    [MailMover]
+    folders = perso/Inbox redhat/Inbox 
+    rename = true
+
+    perso/Inbox = 'NOT tag:Inbox':"perso/[Gmail]/All Mail"
+    redhat/Inbox = 'NOT tag:Inbox':"redhat/[Gmail]/All Mail"
+  '';
+};
+programs.notmuch.enable = true;
+programs.msmtp.enable = true;
+home.packages = with pkgs; [ mu ];
+home.file."bin/msmtp" = {
+  text = ''
+  #!${pkgs.stdenv.shell}
+
+  ${pkgs.msmtp}/bin/msmtp --read-envelope-from $@
+  '';
+  executable = true;
+};
+
+};
 }