Files
home-manager/modules/programs/getmail/default.nix
Austin Horstman 0a2d091b2c getmail: add per-account INI settings
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.
2026-09-21 12:08:57 -05:00

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
);
};
}