Use home-manager account data structures

This commit is contained in:
Simon Bruder 2022-06-16 21:19:04 +02:00
parent 0d125352a3
commit 6d061fa210
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC
3 changed files with 333 additions and 263 deletions

View file

@ -0,0 +1,74 @@
{ config, ... }:
let
signaturePersonal = ''
--
Simon Bruder
Wallmersbach 42
97215 Uffenheim
🔑 (GPG): 47E7 559E 037A 3565 2DBB F8AA 8D3C 82F9 F309 F8EC
📧 (e-mail): simon@sbruder.de
📱 (mobile): +49 152 56561414
'';
in
{
accounts.email = {
accounts = {
personal = rec {
primary = true;
realName = "Simon Bruder";
address = "simon@sbruder.de";
aliases = [ ]; # FIXME!?
userName = address;
passwordCommand = "pass sbruder.de/mail";
imap = {
host = "vueko.sbruder.de";
tls.useStartTls = true;
};
smtp = {
host = "vueko.sbruder.de";
tls.useStartTls = true;
};
gpg = {
key = config.programs.gpg.settings.default-key;
signByDefault = true;
encryptByDefault = true;
};
signature.text = signaturePersonal;
aerc.enable = true;
};
riseup = rec {
realName = "Simon Bruder";
address = "sbruder@riseup.net";
userName = address;
passwordCommand = "pass web/riseup.net | head -n 1";
imap = {
host = "mail.riseup.net";
tls.useStartTls = true;
};
smtp = {
host = "mail.riseup.net";
tls.useStartTls = true;
};
gpg = {
key = config.programs.gpg.settings.default-key;
signByDefault = true;
encryptByDefault = true;
};
signature.text = signaturePersonal;
aerc.enable = true;
};
};
};
}

View file

@ -1,48 +1,42 @@
{ lib, pkgs, ... }: { config, lib, pkgs, ... }:
let let
package = pkgs.aerc; package = pkgs.aerc;
accountDefaults = {
smtp-starttls = "yes";
copy-to = "Sent";
signature-file = pkgs.writeText "signature" ''
--
Simon Bruder
Wallmersbach 42
97215 Uffenheim
🔑 (GPG): 47E7 559E 037A 3565 2DBB F8AA 8D3C 82F9 F309 F8EC
📧 (E-Mail): simon@sbruder.de
📱 (mobile): +49 152 56561414
'';
pgp-auto-sign = true;
pgp-key-id = "47E7559E037A35652DBBF8AA8D3C82F9F309F8EC";
pgp-opportunistic-encrypt = true;
};
in in
{ {
options = {
accounts.email.accounts = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule {
options.aerc.enable = lib.mkEnableOption "aerc";
});
};
};
config = {
home.packages = [ home.packages = [
package package
]; ];
xdg.configFile = { xdg.configFile = {
"aerc/accounts.conf".text = lib.generators.toINI { } { "aerc/accounts.conf".text = lib.generators.toINI { } (lib.mapAttrs
Personal = accountDefaults // { # incomplete support for all configuration options!
source = "`imap://simon%40sbruder.de@vueko.sbruder.de`"; (name: config: with config; let
source-cred-cmd = "`pass sbruder.de/mail`"; quoteMailAddress = lib.replaceChars [ "@" ] [ "%40" ];
outgoing = "`smtp+plain://simon%40sbruder.de@vueko.sbruder.de`"; in
outgoing-cred-cmd = "`pass sbruder.de/mail`"; {
from = "Simon Bruder <simon@sbruder.de>"; source = "`imap://${quoteMailAddress address}@${imap.host}`";
}; source-cred-cmd = "`${lib.concatStringsSep " " passwordCommand}`";
outgoing = "`smtp+plain://${quoteMailAddress address}@${smtp.host}`";
Riseup = accountDefaults // { outgoing-cred-cmd = "`${lib.concatStringsSep " " passwordCommand}`";
source = "`imap://sbruder@mail.riseup.net`"; from = "${realName} <${address}>";
source-cred-cmd = "`pass web/riseup.net | head -n 1`"; smtp-starttls = if smtp.tls.useStartTls then "yes" else "no";
outgoing = "`smtp+plain://sbruder@mail.riseup.net`"; copy-to = "Sent";
outgoing-cred-cmd = "`pass web/riseup.net | head -n 1`"; signature-file = pkgs.writeText "signature-${name}" signature.text;
from = "Simon Bruder <sbruder@riseup.net>"; pgp-key-id = gpg.key;
}; pgp-auto-sign = gpg.signByDefault;
}; pgp-opportunistic-encrypt = gpg.encryptByDefault;
})
(lib.filterAttrs
(_: config: config.aerc.enable)
config.accounts.email.accounts));
"aerc/aerc.conf".text = lib.generators.toINI { } { "aerc/aerc.conf".text = lib.generators.toINI { } {
general = { general = {
@ -275,4 +269,5 @@ in
"completion_default.bg" = 0; "completion_default.bg" = 0;
}); });
}; };
};
} }

View file

@ -1,5 +1,6 @@
{ {
imports = [ imports = [
./accounts.nix
./aerc ./aerc
]; ];
} }