dotfiles/nixng/containers/email/getmail/default.nix
magic_rb 3f2887b439
Switch containers to stable
Signed-off-by: magic_rb <magic_rb@redalder.org>
2024-07-03 17:39:49 +02:00

83 lines
2 KiB
Nix

{
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