dotfiles/nixng/containers/email/getmail/default.nix

83 lines
2 KiB
Nix
Raw Normal View History

{
inputs,
config,
...
}: let
config' = config;
in {
flake.nixngConfigurations.getmail = inputs.nixng.nglib.makeSystem {
system = "x86_64-linux";
name = "ra-systems-getmail";
nixpkgs = inputs.nixpkgs-stable;
config = {
pkgs,
config,
...
}: {
config = {
dumb-init = {
enable = true;
type.services = {};
};
users.users."vmail" = {
uid = config.ids.uids.vmail;
description = "vmail user.";
group = "vmail";
shell = "${pkgs.bash}/bin/bash";
};
users.groups."vmail" = {
gid = config.ids.gids.vmail;
};
init.services.getmail = {
shutdownOnExit = true;
script = let
pkgs' = pkgs.appendOverlays (with config'.flake.overlays; [
courier-unicode
getmail6
maildrop
]);
PATH = with pkgs';
lib.makeBinPath [
jq
busybox
runit
bash
getmail6
maildrop
];
in
pkgs.writeShellScript "getmail-run" ''
export PATH=${PATH}:${pkgs.opensmtpd}/libexec/opensmtpd:$PATH
set -m
for rcfile in /mail-configuration/getmail.d/*.rc
do
filename="$(basename "''${rcfile}")"
email="''${filename%".rc"}"
mkdir -p "/getmail.d/''${email}"
chown vmail:vmail -R "/getmail.d/''${email}"
(
while true
do
chpst -u vmail:vmail getmail -i INBOX -n -r "$rcfile" --getmaildir "/mail-configuration/getmail.d/''${email}"
sleep 10
done
) &
done
wait
'';
enabled = true;
};
};
};
};
}
# /usr/lib/sendmail -i -oem -f %F %T