mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-06 16:57:03 +00:00
accounts/email: provide realName option for alias (#6106)
This commit is contained in:
parent
f0f0d1ade2
commit
c31b4e330e
4 changed files with 39 additions and 14 deletions
|
@ -268,10 +268,26 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
aliases = mkOption {
|
aliases = mkOption {
|
||||||
type = types.listOf (types.strMatching ".*@.*");
|
description = "Alternative identities of this account.";
|
||||||
default = [ ];
|
default = [ ];
|
||||||
example = [ "webmaster@example.org" "admin@example.org" ];
|
example = [ "webmaster@example.org" "admin@example.org" ];
|
||||||
description = "Alternative email addresses of this account.";
|
type = types.listOf (types.oneOf [
|
||||||
|
(types.strMatching ".*@.*")
|
||||||
|
(types.submodule {
|
||||||
|
options = {
|
||||||
|
realName = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
example = "Jane Doe";
|
||||||
|
description = "Name displayed when sending mails.";
|
||||||
|
};
|
||||||
|
address = mkOption {
|
||||||
|
type = types.strMatching ".*@.*";
|
||||||
|
example = "jane.doe@example.org";
|
||||||
|
description = "The email address of this identity.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
realName = mkOption {
|
realName = mkOption {
|
||||||
|
|
|
@ -16,7 +16,8 @@ let
|
||||||
filter (a: a.mu.enable) (attrValues config.accounts.email.accounts);
|
filter (a: a.mu.enable) (attrValues config.accounts.email.accounts);
|
||||||
addrs = map (a: a.address) muAccounts;
|
addrs = map (a: a.address) muAccounts;
|
||||||
# Construct list of lists containing email aliases, and flatten
|
# Construct list of lists containing email aliases, and flatten
|
||||||
aliases = flatten (map (a: a.aliases) muAccounts);
|
aliases = map (alias: alias.address or alias)
|
||||||
|
(flatten (map (a: a.aliases) muAccounts));
|
||||||
# Sort the list
|
# Sort the list
|
||||||
in sort lessThan (addrs ++ aliases);
|
in sort lessThan (addrs ++ aliases);
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,9 @@ let
|
||||||
in {
|
in {
|
||||||
name = catAttrs "realName" primary;
|
name = catAttrs "realName" primary;
|
||||||
primary_email = catAttrs "address" primary;
|
primary_email = catAttrs "address" primary;
|
||||||
other_email = catAttrs "aliases" primary ++ catAttrs "address" secondaries
|
other_email = map (email: email.address or email) (flatten
|
||||||
++ catAttrs "aliases" secondaries;
|
(catAttrs "aliases" primary ++ catAttrs "address" secondaries
|
||||||
|
++ catAttrs "aliases" secondaries));
|
||||||
};
|
};
|
||||||
|
|
||||||
search = { exclude_tags = cfg.search.excludeTags; };
|
search = { exclude_tags = cfg.search.excludeTags; };
|
||||||
|
|
|
@ -49,16 +49,25 @@ let
|
||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
getId = account: address:
|
||||||
|
if address == account.address then
|
||||||
|
account.id
|
||||||
|
else
|
||||||
|
(builtins.hashString "sha256" (if (builtins.isString address) then
|
||||||
|
address
|
||||||
|
else
|
||||||
|
(address.address + address.realName)));
|
||||||
|
|
||||||
toThunderbirdIdentity = account: address:
|
toThunderbirdIdentity = account: address:
|
||||||
# For backwards compatibility, the primary address reuses the account ID.
|
# For backwards compatibility, the primary address reuses the account ID.
|
||||||
let
|
let
|
||||||
id = if address == account.address then
|
id = getId account address;
|
||||||
account.id
|
addressIsString = builtins.isString address;
|
||||||
else
|
|
||||||
builtins.hashString "sha256" address;
|
|
||||||
in {
|
in {
|
||||||
"mail.identity.id_${id}.fullName" = account.realName;
|
"mail.identity.id_${id}.fullName" =
|
||||||
"mail.identity.id_${id}.useremail" = address;
|
if addressIsString then account.realName else address.realName;
|
||||||
|
"mail.identity.id_${id}.useremail" =
|
||||||
|
if addressIsString then address else address.address;
|
||||||
"mail.identity.id_${id}.valid" = true;
|
"mail.identity.id_${id}.valid" = true;
|
||||||
"mail.identity.id_${id}.htmlSigText" =
|
"mail.identity.id_${id}.htmlSigText" =
|
||||||
if account.signature.showSignature == "none" then
|
if account.signature.showSignature == "none" then
|
||||||
|
@ -87,9 +96,7 @@ let
|
||||||
addresses = [ account.address ] ++ account.aliases;
|
addresses = [ account.address ] ++ account.aliases;
|
||||||
in {
|
in {
|
||||||
"mail.account.account_${id}.identities" = concatStringsSep ","
|
"mail.account.account_${id}.identities" = concatStringsSep ","
|
||||||
([ "id_${id}" ]
|
(map (address: "id_${getId account address}") addresses);
|
||||||
++ map (address: "id_${builtins.hashString "sha256" address}")
|
|
||||||
account.aliases);
|
|
||||||
"mail.account.account_${id}.server" = "server_${id}";
|
"mail.account.account_${id}.server" = "server_${id}";
|
||||||
} // optionalAttrs account.primary {
|
} // optionalAttrs account.primary {
|
||||||
"mail.accountmanager.defaultaccount" = "account_${id}";
|
"mail.accountmanager.defaultaccount" = "account_${id}";
|
||||||
|
|
Loading…
Add table
Reference in a new issue