home

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit feb667a5ee3e1ac12322da73044aae023536854f
parent 9b538a800879ca4e721b2d40b95c0496d279a425
Author: Vincent Demeester <vincent@sbr.pm>
Date:   Fri, 19 Jun 2020 21:49:44 +0200

users/vincent: add gmailctl to mails

and formal mails module.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Diffstat:
Musers/modules/profiles/mails.nix | 339+++++++++++++++++++++++++++++++++++++++----------------------------------------
Musers/vincent/mails/default.nix | 2++
2 files changed, 168 insertions(+), 173 deletions(-)

diff --git a/users/modules/profiles/mails.nix b/users/modules/profiles/mails.nix @@ -20,196 +20,189 @@ in }; }; - config = - mkIf - cfg.enable - ( - mkMerge [ - { - - 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"; - }; - account = { - Timeout = 120; - PipelineDepth = 1; - }; - }; - }; - notmuch.enable = cfg.sync; - astroid.enable = cfg.sync; - msmtp.enable = true; + config = mkIf cfg.enable (mkMerge [ + { + 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"; }; - "perso" = { - 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"; - }; - account = { - Timeout = 120; - PipelineDepth = 1; - }; - }; - }; - notmuch.enable = cfg.sync; - astroid.enable = cfg.sync; - msmtp.enable = true; + account = { + Timeout = 120; + PipelineDepth = 1; }; - "prv" = { - primary = true; - address = "vincent@demeester.fr"; - userName = "vincent@demeester.fr"; - 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/prv.pass -d ${config.home.homeDirectory}/desktop/documents/prv.pass.gpg"; - imap.host = "mail.gandi.net"; - smtp.host = "mail.gandi.net"; - mbsync = { - enable = true; - create = "both"; - expunge = "both"; - patterns = [ "*" ]; - extraConfig = { - channel = { - Sync = "All"; - }; - account = { - Timeout = 120; - PipelineDepth = 1; - }; - }; - }; - notmuch.enable = cfg.sync; - astroid.enable = cfg.sync; - msmtp.enable = true; + }; + }; + notmuch.enable = cfg.sync; + astroid.enable = cfg.sync; + msmtp.enable = true; + }; + "perso" = { + 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"; + }; + account = { + Timeout = 120; + PipelineDepth = 1; }; }; }; - - home.file."bin/msmtp" = { - text = '' - #!${pkgs.stdenv.shell} - ${pkgs.libnotify}/bin/notify-send "Sending mail ✉️" - ${pkgs.msmtp}/bin/msmtp --read-envelope-from $@ - ''; - executable = true; + notmuch.enable = cfg.sync; + astroid.enable = cfg.sync; + msmtp.enable = true; + }; + "prv" = { + primary = true; + address = "vincent@demeester.fr"; + userName = "vincent@demeester.fr"; + 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/prv.pass -d ${config.home.homeDirectory}/desktop/documents/prv.pass.gpg"; + imap.host = "mail.gandi.net"; + smtp.host = "mail.gandi.net"; + mbsync = { + enable = true; + create = "both"; + expunge = "both"; + patterns = [ "*" ]; + extraConfig = { + channel = { + Sync = "All"; + }; + account = { + Timeout = 120; + PipelineDepth = 1; + }; + }; }; + notmuch.enable = cfg.sync; + astroid.enable = cfg.sync; + msmtp.enable = true; + }; + }; + }; - programs.msmtp.enable = true; + home.file."bin/msmtp" = { + text = '' + #!${pkgs.stdenv.shell} + ${pkgs.libnotify}/bin/notify-send "Sending mail ✉️" + ${pkgs.msmtp}/bin/msmtp --read-envelope-from $@ + ''; + executable = true; + }; - } + programs.msmtp.enable = true; - ( - mkIf cfg.sync { + } - services.mbsync = { - enable = true; - preExec = "${config.xdg.configHome}/mbsync/preExec"; - postExec = "${config.xdg.configHome}/mbsync/postExec"; - frequency = cfg.frequency; - }; + (mkIf cfg.sync { - xdg.configFile."mbsync/preExec" = { - text = '' - #!${pkgs.stdenv.shell} + services.mbsync = { + enable = true; + preExec = "${config.xdg.configHome}/mbsync/preExec"; + postExec = "${config.xdg.configHome}/mbsync/postExec"; + frequency = cfg.frequency; + }; - export NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/notmuchrc - export NMBGIT=${config.xdg.dataHome}/notmuch/nmbug + xdg.configFile."mbsync/preExec" = { + text = '' + #!${pkgs.stdenv.shell} - ${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; - }; + export NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/notmuchrc + export NMBGIT=${config.xdg.dataHome}/notmuch/nmbug - 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 - # Remove inbox (lower-case) - ${pkgs.notmuch}/bin/notmuch tag -inbox -- tag:inbox - # Remove Inbox tagged message that are not in an Inbox - ${pkgs.notmuch}/bin/notmuch tag -Inbox -- not folder:redhat/Inbox and not folder:perso/Inbox and tag:Inbox - ${pkgs.libnotify}/bin/notify-send "Mails synced 📬" - ''; - executable = true; - }; + ${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; + }; - home.file."bin/msync" = { - text = '' - #!${pkgs.stdenv.shell} - ${pkgs.libnotify}/bin/notify-send "Syncing mails 📫️" - systemctl --user start mbsync - ''; - 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 + # Remove inbox (lower-case) + ${pkgs.notmuch}/bin/notmuch tag -inbox -- tag:inbox + # Remove Inbox tagged message that are not in an Inbox + ${pkgs.notmuch}/bin/notmuch tag -Inbox -- not folder:redhat/Inbox and not folder:perso/Inbox and tag:Inbox + ${pkgs.libnotify}/bin/notify-send "Mails synced 📬" + ''; + executable = true; + }; - programs.mbsync.enable = true; - programs.notmuch.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" - ''; - }; + home.file."bin/msync" = { + text = '' + #!${pkgs.stdenv.shell} + ${pkgs.libnotify}/bin/notify-send "Syncing mails 📫️" + systemctl --user start mbsync + ''; + executable = true; + }; - programs.astroid = { - enable = true; - externalEditor = "emacsclient -c"; - extraConfig = { - startup.queries.inbox = "tag:Inbox"; - startup.queries.inbox_perso = "folder:perso/Inbox"; - startup.queries.inbox_redhat = "folder:redhat/Inbox"; - }; - }; + programs.mbsync.enable = true; + programs.notmuch.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.astroid = { + enable = true; + externalEditor = "emacsclient -c"; + extraConfig = { + startup.queries.inbox = "tag:Inbox"; + startup.queries.inbox_perso = "folder:perso/Inbox"; + startup.queries.inbox_redhat = "folder:redhat/Inbox"; + }; + }; - } - ) + } + ) - ] - ); + ]); } diff --git a/users/vincent/mails/default.nix b/users/vincent/mails/default.nix @@ -8,4 +8,6 @@ in enable = true; sync = sync; }; + home.file.".gmailctl/config.jsonnet".source = ./config.jsonnet; + home.packages = with pkgs; [ gmailctl ]; }