refactor: centralize host and user metadata
This commit is contained in:
+21
-34
@@ -1,17 +1,23 @@
|
||||
{ ... }:
|
||||
{
|
||||
flake.modules.homeManager.email =
|
||||
{ config, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
realName = "Jelle Spreeuwenberg";
|
||||
user = config.meta.user;
|
||||
mkOffice365Account =
|
||||
{
|
||||
address,
|
||||
primary,
|
||||
...
|
||||
}:
|
||||
{
|
||||
enable = true;
|
||||
inherit address primary realName;
|
||||
inherit address primary;
|
||||
realName = user.realName;
|
||||
userName = address;
|
||||
thunderbird = {
|
||||
enable = true;
|
||||
@@ -26,10 +32,12 @@
|
||||
{
|
||||
address,
|
||||
primary,
|
||||
...
|
||||
}:
|
||||
{
|
||||
enable = true;
|
||||
inherit address primary realName;
|
||||
inherit address primary;
|
||||
realName = user.realName;
|
||||
userName = address;
|
||||
thunderbird.enable = true;
|
||||
imap = {
|
||||
@@ -45,6 +53,14 @@
|
||||
tls.enable = true;
|
||||
};
|
||||
};
|
||||
mkEmailAccount =
|
||||
email:
|
||||
if email.type == "office365" then
|
||||
mkOffice365Account email
|
||||
else if email.type == "mxrouting" then
|
||||
mkMxrouteAccount email
|
||||
else
|
||||
throw "Unsupported email type `${email.type}` for ${config.home.username}";
|
||||
in
|
||||
{
|
||||
programs.thunderbird = {
|
||||
@@ -65,35 +81,6 @@
|
||||
};
|
||||
};
|
||||
|
||||
accounts.email.accounts =
|
||||
if config.home.username == "ergon" then
|
||||
{
|
||||
work = mkOffice365Account {
|
||||
address = "jelle.spreeuwenberg@yookr.org";
|
||||
primary = true;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
main = mkMxrouteAccount {
|
||||
address = "mail@jelles.net";
|
||||
primary = true;
|
||||
};
|
||||
|
||||
old = mkMxrouteAccount {
|
||||
address = "mail@jellespreeuwenberg.nl";
|
||||
primary = false;
|
||||
};
|
||||
|
||||
uni = mkOffice365Account {
|
||||
address = "j.spreeuwenberg@student.tue.nl";
|
||||
primary = false;
|
||||
};
|
||||
|
||||
work = mkOffice365Account {
|
||||
address = "jelle.spreeuwenberg@yookr.org";
|
||||
primary = false;
|
||||
};
|
||||
};
|
||||
accounts.email.accounts = lib.mapAttrs (_: mkEmailAccount) user.emails;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user