From 579e5ec220a2d447bce1bc6a4ec59451e2837ee1 Mon Sep 17 00:00:00 2001 From: traxys Date: Fri, 26 May 2023 13:50:27 +0200 Subject: [PATCH] thinkpad-nixos: Use notmuch for work mails --- hostconfig/thinkpad-nixos/hm.nix | 235 +++++++++++++++++++++++++++- hostconfig/thinkpad-nixos/nixos.nix | 6 + 2 files changed, 240 insertions(+), 1 deletion(-) diff --git a/hostconfig/thinkpad-nixos/hm.nix b/hostconfig/thinkpad-nixos/hm.nix index edaead7..e864159 100644 --- a/hostconfig/thinkpad-nixos/hm.nix +++ b/hostconfig/thinkpad-nixos/hm.nix @@ -36,6 +36,7 @@ home.sessionVariables = { OPENSC_SO = "${pkgs.opensc}"; + EMAIL_CONN_TEST = "s"; }; home.file = { @@ -59,13 +60,245 @@ }; }; + programs.mbsync.enable = true; + programs.msmtp.enable = true; + programs.aerc = { + enable = true; + extraAccounts = { + work-t = let + workCfg = config.accounts.email.accounts.work.aerc; + in { + inherit + (workCfg.extraAccounts) + check-mail-cmd + check-mail-timeout + ; + from = "Quentin Boyer "; + outgoing = "msmtpq --read-envelope-from --read-recipients"; + default = "Inbox"; + postpone = "Drafts"; + source = "notmuch://~/Maildir"; + query-map = "${pkgs.writeText "querymap" '' + Inbox=path:work/Inbox/** + bxi3=tag:bxi3 + libs2=tag:libs2 + inflight=thread:{tag:inflight} + review=thread:{tag:review} + btf=tag:btf + ''}"; + }; + }; + extraConfig = { + general.unsafe-accounts-conf = true; + ui = { + mouse-enabled = true; + threading-enabled = true; + }; + filters = { + "text/plain" = "colorize"; + "text/calendar" = "calendar"; + "message/delivery-status" = "colorize"; + "message/rfc822" = "colorize"; + "text/html" = "html | colorize"; + "subject,~^\\[PATCH" = "delta"; + }; + }; + extraBinds = { + global = { + "" = ":prev-tab"; + "" = ":next-tab"; + "" = ":term"; + "?" = ":help keys"; + }; + + messages = { + "q" = ":quit"; + + "j" = ":next"; + "" = ":next"; + "" = ":next 100%"; + + "k" = ":prev"; + "" = ":prev"; + "" = ":prev 100%"; + + "g" = ":select 0"; + "G" = ":select -1"; + + "J" = ":next-folder"; + "K" = ":prev-folder"; + + "T" = ":toggle-threads"; + + "" = ":view"; + + "C" = ":compose"; + + "" = ":read"; + + "rr" = ":reply -a"; + "rq" = ":reply -aq"; + "Rr" = ":reply"; + "Rq" = ":reply -q"; + + "/" = ":search"; + "\\" = ":filter"; + "n" = ":next-result"; + "N" = ":prev-result"; + "" = ":clear"; + + "tdi" = ":tag -inflight:select 0"; + "tdr" = ":tag -review:select 0"; + }; + + view = { + "/" = ":toggle-key-passthrough/"; + + "q" = ":close"; + "O" = ":open"; + "S" = ":save"; + "D" = ":delete"; + "" = ":open-link "; + "f" = ":forward"; + + "rr" = ":reply -a"; + "rq" = ":reply -aq"; + "Rr" = ":reply"; + "Rq" = ":reply -q"; + + "H" = ":toggle-headers"; + "" = ":prev-part"; + "" = ":prev-part"; + "J" = ":next"; + "K" = ":prev"; + }; + + "view::passthrough" = { + "$noinherit" = "true"; + "$ex" = ""; + "" = ":toggle-key-passthrough"; + }; + + compose = { + "$noinherit" = true; + "$ex" = ""; + + "" = ":prev-field"; + "" = ":next-field"; + + "" = ":next-field"; + "" = ":prev-field"; + + "" = ":prev-tab"; + "" = ":next-tab"; + }; + + "compose::editor" = { + "$noinherit" = true; + "$ex" = ""; + + "" = ":prev-field"; + "" = ":next-field"; + + "" = ":prev-tab"; + "" = ":next-tab"; + }; + + "compose::review" = { + "y" = ":send"; + "n" = ":abort"; + "v" = ":preview"; + "p" = ":postpone"; + "q" = ":choose -o d discard abort -o p postpone postpone"; + "e" = ":edit"; + "a" = ":attach"; + "d" = ":detach"; + }; + }; + }; + + programs.notmuch = { + enable = true; + new.tags = ["new"]; + hooks = { + preNew = "mbsync --all"; + postNew = let + mkProjectMatch = project: "subject:'/PATCH\\s${project}/'"; + mkProjectMatches = labels: lib.concatStringsSep " or " (builtins.map mkProjectMatch labels); + + mkProject = tag: labels: '' + notmuch tag +${tag} +unread -new -- tag:new and \( ${mkProjectMatches labels} \) + ''; + in '' + notmuch tag -new -unread -- tag:new and from:quentin.boyer@***REMOVED*** + notmuch tag +work -- tag:new and 'path:work/**' + notmuch tag +inflight -- tag:new and from:quentin.boyer@***REMOVED*** and subject:'/^\[PATCH/' + notmuch tag +review -- tag:new and not from:quentin.boyer@***REMOVED*** and subject:'/^\[PATCH/' + ${mkProject "btf" ["bxi-test-frameworks" "bxi-frameworks"]} + ${mkProject "bxi3" ["bxi3"]} + ${mkProject "libs2" ["bxi-jenkins-libs2"]} + ${mkProject "hps" ["bxi-hps"]} + notmuch tag +inbox +unread -new -- tag:new + ''; + }; + }; + + accounts.email = { + accounts.work = rec { + address = "quentin.boyer@***REMOVED***"; + imap = { + host = "localhost"; + port = 1143; + tls.enable = false; + }; + mbsync = { + enable = true; + create = "maildir"; + subFolders = "Verbatim"; + extraConfig.account = { + AuthMechs = "LOGIN"; + }; + }; + passwordCommand = "echo foobar"; + notmuch.enable = true; + msmtp = { + enable = true; + extraConfig.auth = "plain"; + }; + primary = true; + realName = "Quentin Boyer"; + userName = address; + smtp = { + host = "localhost"; + port = 1025; + tls.enable = false; + }; + + aerc = { + enable = true; + extraAccounts = { + check-mail-cmd = "notmuch new"; + check-mail-timeout = "60s"; + }; + }; + }; + }; + xdg.desktopEntries.teams = { name = "teams"; exec = "${pkgs.chromium}/bin/chromium --app=https://teams.microsoft.com"; }; programs.zsh.shellAliases = { - gemail = "git send-email --to='dl-bxi-sw-ll-patches@***REMOVED***'"; + gemail = let + nwadminSendmail = pkgs.writeScript "nwadmin-sendmail" '' + #!/usr/bin/env sh + + # shellcheck disable=SC2029 + ssh nwadmin "/usr/sbin/sendmail -r quentin.boyer@***REMOVED*** $*" + exit $? + ''; + in ''git send-email --sendmail-cmd="${nwadminSendmail}" --to="dl-bxi-sw-ll-patches@***REMOVED***"''; }; home.stateVersion = "21.11"; diff --git a/hostconfig/thinkpad-nixos/nixos.nix b/hostconfig/thinkpad-nixos/nixos.nix index 2880eb8..a03a4ab 100644 --- a/hostconfig/thinkpad-nixos/nixos.nix +++ b/hostconfig/thinkpad-nixos/nixos.nix @@ -13,6 +13,12 @@ efi.canTouchEfiVariables = true; }; + environment.systemPackages = [ + (pkgs.davmail.overrideAttrs (old: { + nativeBuildInputs = old.nativeBuildInputs ++ [pkgs.swt]; + })) + ]; + boot.kernelParams = ["intel_iommu=on" "iommu=pt"]; networking = {