mu cfind

Changed files
+12 -62
home
pkgs
+12 -37
home/mail.nix
···
let
address-book = pkgs.writeScriptBin "address-book" ''
#!/usr/bin/env bash
-
${pkgs.ugrep}/bin/ugrep -jPh -m 100 --color=never "$1"\
-
${config.accounts.email.maildirBasePath}/addressbook/maildir\
-
${config.accounts.email.maildirBasePath}/addressbook/cam-ldap
+
${pkgs.mu}/bin/mu cfind "$1" | sed -E 's/(.*) (.*@.*)/\2\t\1/'
+
${pkgs.ugrep}/bin/ugrep -jPh -m 100 --color=never "$1" cat ${config.accounts.email.maildirBasePath}/addressbook/cam-ldap)
'';
sync-mail = pkgs.writeScriptBin "sync-mail" ''
#!/usr/bin/env bash
-
${pkgs.isync}/bin/mbsync "$1"
+
${pkgs.isync}/bin/mbsync "$1" || exit 1
${pkgs.procps}/bin/pkill -2 -x mu
+
sleep 1
${pkgs.mu}/bin/mu index
'';
cfg = config.custom.mail;
···
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
-
(callPackage ../pkgs/maildir-rank-addr.nix { })
(pkgs.writeScriptBin "cam-ldap-addr" ''
${pkgs.openldap}/bin/ldapsearch -xZ -H ldaps://ldap.lookup.cam.ac.uk -b "ou=people,o=University of Cambridge,dc=cam,dc=ac,dc=uk" displayName mail\
| ${pkgs.gawk}/bin/awk '/^dn:/{displayName=""; mail=""; next} /^displayName:/{displayName=$2; for(i=3;i<=NF;i++) displayName=displayName " " $i; next} /^mail:/{mail=$2; next} /^$/{if(displayName!="" && mail!="") print mail "\t" displayName}'\
> ${config.accounts.email.maildirBasePath}/addressbook/cam-ldap
'')
address-book
+
sync-mail
];
-
xdg.configFile = {
-
"maildir-rank-addr/config".text = with config.accounts.email; ''
-
maildir = "${config.accounts.email.maildirBasePath}"
-
outputpath = "${config.accounts.email.maildirBasePath}/addressbook/maildir"
-
addresses = [
-
"ryan@freumh.org",
-
"misc@freumh.org",
-
"ryan@gibbr.org",
-
"misc@gibbr.org",
-
"ryan.gibb@cl.cam.ac.uk",
-
"rtg24@cam.ac.uk",
-
"rtg2@st-andrews.ac.uk",
-
"ryangibb321@gmail.com",
-
"ryangibb@btconnect.com",
-
]
-
'';
-
};
-
programs = {
password-store.enable = true;
gpg.enable = true;
···
imapnotify = {
enable = true;
boxes = [ "Inbox" ];
-
onNotify =
-
"${pkgs.isync}/bin/mbsync ryan@freumh.org && (${pkgs.procps}/bin/pkill -2 -x mu; sleep 1; ${pkgs.mu}/bin/mu index)";
+
onNotify = "${sync-mail}/bin/mbsync ryan@freumh.org";
};
mbsync = {
enable = true;
···
aerc = {
enable = true;
extraAccounts = {
-
check-mail-cmd =
-
"${pkgs.isync}/bin/mbsync ryan@freumh.org && (${pkgs.procps}/bin/pkill -2 -x mu; sleep 1; ${pkgs.mu}/bin/mu index)";
+
check-mail-cmd = "${sync-mail}/bin/mbsync ryan@freumh.org";
check-mail-timeout = "1m";
check-mail = "1h";
folders-sort =
···
imapnotify = {
enable = true;
boxes = [ "Inbox" ];
-
onNotify =
-
"${pkgs.isync}/bin/mbsync misc@freumh.org && (${pkgs.procps}/bin/pkill -2 -x mu; sleep 1; ${pkgs.mu}/bin/mu index)";
+
onNotify = "${sync-mail}/bin/mbsync misc@freumh.org";
};
mbsync = {
enable = true;
···
imapnotify = {
enable = true;
boxes = [ "Inbox" ];
-
onNotify =
-
"${pkgs.isync}/bin/mbsync ryan.gibb@cl.cam.ac.uk && (${pkgs.procps}/bin/pkill -2 -x mu; sleep 1; ${pkgs.mu}/bin/mu index)";
+
onNotify = "${sync-mail}/bin/mbsync ryan.gibb@cl.cam.ac.uk";
};
mbsync = {
enable = true;
···
aerc = {
enable = true;
extraAccounts = {
-
check-mail-cmd =
-
"${pkgs.isync}/bin/mbsync ryan.gibb@cl.cam.ac.uk && (${pkgs.procps}/bin/pkill -2 -x mu; sleep 1; ${pkgs.mu}/bin/mu index)";
+
check-mail-cmd = "${sync-mail}/bin/mbsync ryan.gibb@cl.cam.ac.uk";
check-mail-timeout = "1m";
check-mail = "1h";
aliases = "rtg24@cam.ac.uk";
···
imapnotify = {
enable = true;
boxes = [ "Inbox" ];
-
onNotify =
-
"${pkgs.isync}/bin/mbsync ryangibb321@gmail.com && (${pkgs.procps}/bin/pkill -2 -x mu; sleep 1; ${pkgs.mu}/bin/mu index)";
+
onNotify = "${sync-mail}/bin/mbsync ryangibb321@gmail.com";
};
mbsync = {
enable = true;
···
aerc = {
enable = true;
extraAccounts = {
-
check-mail-cmd =
-
"${pkgs.isync}/bin/mbsync ryangibb321@gmail.com && (${pkgs.procps}/bin/pkill -2 -x mu; sleep 1; ${pkgs.mu}/bin/mu index)";
+
check-mail-cmd = "${sync-mail}/bin/mbsync ryangibb321@gmail.com";
check-mail-timeout = "1m";
check-mail = "1h";
folders-sort = [
-25
pkgs/maildir-rank-addr.nix
···
-
{ lib, buildGoModule, fetchFromGitHub }:
-
-
buildGoModule rec {
-
pname = "maildir-rank-addr";
-
version = "1.3.0";
-
-
src = fetchFromGitHub {
-
owner = "ferdinandyb";
-
repo = "maildir-rank-addr";
-
rev = "v${version}";
-
hash = "sha256-LABqd9FojbQUG3c0XBH5ZKsJNPTMEt3Yzn6gpYEWddc=";
-
};
-
-
vendorHash = "sha256-Mqx938j8LwM+bDnrK3V46FFy86JbVoh9Zxr/CA/egk8=";
-
-
meta = with lib; {
-
description =
-
"Creates a ranked list of email addresses from maildir folders";
-
homepage = "https://github.com/ferdinandyb/maildir-rank-addr/";
-
maintainers = with maintainers; [ ryangibb ];
-
mainProgram = "maildir-rank-addr";
-
license = licenses.mit;
-
platforms = platforms.unix;
-
};
-
}