{ user, userName }: { lib, pkgs, config, ... }: with lib; let cfg = config.roles.email; terminal = config.programs.terminal.package; termcmd = "${terminal}/bin/${terminal.pname}"; in { options.roles = { email = { enable = mkEnableOption "email settings"; email = mkOption { description = "email address"; }; terminal = mkOption { type = types.bool; default = true; }; }; }; config = mkIf cfg.enable { programs.scripts = [ { name = "email"; text = '' ${termcmd} -e aerc ''; install = false; hotkeys = [{key = "E";}]; } ]; home-manager.users.${user}.imports = [{ programs.git = { userName = userName; userEmail = cfg.email; }; accounts.email.accounts.${cfg.email} = mkIf cfg.terminal { notmuch.enable = true; neomutt.enable = true; aerc.enable = true; mbsync.enable = true; mbsync.create = "both"; userName = cfg.email; realName = userName; address = cfg.email; primary = true; passwordCommand = "${pkgs.rbw}/bin/rbw get privateemail"; smtp = { host = "mail.privateemail.com"; port = 465; tls.enable = true; }; imap = { host = "mail.privateemail.com"; port = 993; tls.enable = true; }; }; programs.notmuch.enable = cfg.terminal; programs.neomutt = { enable = cfg.terminal; vimKeys = true; sort = "reverse-date"; sidebar.enable = true; }; programs.mbsync.enable = cfg.terminal; services.mbsync.enable = cfg.terminal; programs.aerc = { enable = cfg.terminal; extraBinds = '' # Binds are of the form = # To use '=' in a key sequence, substitute it with "Eq": "" # If you wish to bind #, you can wrap the key sequence in quotes: "#" = quit = :prev-tab = :next-tab = :term [messages] Q = :quit T = :toggle-threads j = :next = :next = :next 50% = :next 100% = :next -s 100% k = :prev = :prev = :prev 50% = :prev = :prev -s 100% gg = :select 0 G = :select -1 J = :next-folder K = :prev-folder v = :mark -t V = :mark -v f = :flag F = :unflag t = :toggle-threads = :view D = :delete C = :compose Rr = :reply Rq = :reply -q rr = :reply -a rq = :reply -aq rt = :unflag:reply -a -Tthanks Rt = :unflag:reply -qa -Tquoted_thanks a = :mv Archive c = :cf $ = :term ! = :term | = :pipe ga = :flag:pipe -mb git am -3 gp = :term git push gl = :term git log / = :search \ = :filter n = :next-result N = :prev-result o = :term mbsync -a q = :quit [view] / = :toggle-key-passthrough/ q = :close | = :pipe -m S = :save H = :toggle-headers D = :delete = :prev-part = :next-part J = :next K = :prev f = :forward Rr = :reply Rq = :reply -q rr = :reply -a rq = :reply -aq rt = :reply -Tthanks ga = :pipe -b git am -3 gp = :term git push gl = :term git log [view::passthrough] $noinherit = true $ex = = :toggle-key-passthrough [compose] $ex = = :prev-field = :next-field = :next-field [compose::editor] # Keybindings used when the embedded terminal is selected in the compose view $noinherit = true $ex = = :term = :prev-field = :next-field = :prev-tab = :next-tab [compose::review] # Keybindings used when reviewing a message to be sent y = :send n = :abort e = :edit a = :attach c = :encrypt s = :sign V = :header -f X-Sourcehut-Patchset-Update NEEDS_REVISION A = :header -f X-Sourcehut-Patchset-Update APPLIED R = :header -f X-Sourcehut-Patchset-Update REJECTED [terminal] $noinherit = true $ex = = :term = :prev-tab = :next-tab ''; extraConfig = { general = { pgp-provider = "gpg"; unsafe-accounts-conf = true; }; ui = { }; viewer = { }; filters = { "text/plain" = "colorize"; "text/calendar" = "calendar"; "message/delivery-status" = "colorize"; "message/rfc822" = "colorize"; "image/*" = "img2sixel"; "text/html" = "html | colorize"; }; }; }; }]; }; }