default.nix (3552B)
1 { 2 lib, 3 options, 4 config, 5 pkgs, 6 ... 7 }: 8 { 9 options.modules.aerc = { 10 enable = lib.mkOption { 11 description = "Whether to enable aerc."; 12 default = false; 13 type = lib.types.bool; 14 }; 15 email = { 16 address = lib.mkOption { 17 description = "The email address."; 18 type = lib.types.uniq lib.types.str; 19 }; 20 folders = { 21 drafts = lib.mkOption { 22 description = "The drafts folder."; 23 type = lib.types.uniq lib.types.str; 24 }; 25 inbox = lib.mkOption { 26 description = "The inbox folder."; 27 type = lib.types.uniq lib.types.str; 28 }; 29 sent = lib.mkOption { 30 description = "The sent folder."; 31 type = lib.types.uniq lib.types.str; 32 }; 33 trash = lib.mkOption { 34 description = "The spam folder."; 35 type = lib.types.uniq lib.types.str; 36 }; 37 }; 38 imapHost = lib.mkOption { 39 description = "The IMAP server name."; 40 type = lib.types.uniq lib.types.str; 41 }; 42 imapTlsPort = lib.mkOption { 43 description = "The IMAP port. If null then the default port is used."; 44 type = lib.types.nullOr lib.types.int; 45 }; 46 passwordCommand = lib.mkOption { 47 description = '' 48 The command which returns the password to login to the email 49 account. 50 ''; 51 type = lib.types.uniq lib.types.str; 52 }; 53 realName = lib.mkOption { 54 description = "The name used as recipient."; 55 type = lib.types.uniq lib.types.str; 56 }; 57 smtpHost = lib.mkOption { 58 description = "The SMTP server name."; 59 type = lib.types.uniq lib.types.str; 60 }; 61 smtpTlsPort = lib.mkOption { 62 description = "The SMTP port. If null then the default port is used."; 63 type = lib.types.nullOr lib.types.int; 64 }; 65 username = lib.mkOption { 66 description = "The username used to login to the email account."; 67 type = lib.types.uniq lib.types.str; 68 }; 69 }; 70 }; 71 72 config = lib.mkIf config.modules.aerc.enable { 73 programs.aerc = { 74 enable = true; 75 package = pkgs.aerc; 76 77 extraConfig = { 78 general = { 79 unsafe-accounts-conf = true; 80 }; 81 viewer.pager = "${pkgs.less}/bin/less --clear-screen"; 82 compose.editor = "${pkgs.nano}/bin/nano"; 83 filters = { 84 "text/plain" = "${pkgs.ccze}/bin/ccze --mode=ansi --raw-ansi"; 85 "text/html" = "${pkgs.pandoc}/bin/pandoc -f html -t plain"; 86 }; 87 }; 88 }; 89 90 accounts.email = { 91 accounts.${config.modules.aerc.email.address} = { 92 aerc.enable = true; 93 94 inherit (config.modules.aerc.email) 95 address 96 folders 97 passwordCommand 98 realName 99 ; 100 101 flavor = "plain"; 102 gpg = lib.mkIf config.modules.gpg.enable { 103 key = config.modules.gpg.primaryKey.fingerprint; 104 signByDefault = true; 105 }; 106 imap = { 107 host = config.modules.aerc.email.imapHost; 108 port = config.modules.aerc.email.imapTlsPort; 109 tls = { 110 enable = true; 111 useStartTls = false; 112 }; 113 }; 114 primary = true; 115 smtp = { 116 host = config.modules.aerc.email.smtpHost; 117 port = config.modules.aerc.email.smtpTlsPort; 118 tls = { 119 enable = true; 120 useStartTls = false; 121 }; 122 }; 123 userName = config.modules.aerc.email.username; 124 }; 125 }; 126 }; 127 }