mirror of
https://github.com/nix-community/home-manager.git
synced 2026-11-03 03:10:20 +00:00
Expose native filter, retriever, and destination configuration while retaining account defaults and legacy boolean aliases. Preserve tuple rendering and allow complete native retriever configuration without an IMAP account block.
38 lines
966 B
Nix
38 lines
966 B
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
iniFormat = pkgs.formats.ini { };
|
|
accounts = lib.filter (a: a.enable && a.getmail.enable) (
|
|
lib.attrValues config.accounts.email.accounts
|
|
);
|
|
|
|
renderAccountConfig =
|
|
account: "# Generated by Home-Manager.\n" + lib.generators.toINI { } account.getmail.settings;
|
|
|
|
getmailEnabled = lib.length accounts > 0;
|
|
# Watch out! This is used by the getmail.service too!
|
|
renderConfigFilepath = a: ".getmail/getmail${if a.primary then "rc" else a.name}";
|
|
|
|
in
|
|
{
|
|
options = {
|
|
accounts.email.accounts = lib.mkOption {
|
|
type = lib.types.attrsOf (lib.types.submodule (import ./accounts.nix { inherit iniFormat; }));
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf getmailEnabled {
|
|
assertions = [
|
|
(lib.hm.assertions.assertPlatform "programs.getmail" pkgs lib.platforms.linux)
|
|
];
|
|
|
|
home.file = lib.mergeAttrsList (
|
|
map (a: { "${renderConfigFilepath a}".text = renderAccountConfig a; }) accounts
|
|
);
|
|
};
|
|
}
|