2023-06-13 23:05:53 +02:00
|
|
|
{
|
2024-03-02 22:05:30 +01:00
|
|
|
inputs,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
config' = config;
|
|
|
|
in {
|
2023-06-13 23:05:53 +02:00
|
|
|
flake.nixngConfigurations.getmail = inputs.nixng.nglib.makeSystem {
|
|
|
|
system = "x86_64-linux";
|
|
|
|
name = "ra-systems-getmail";
|
2024-07-03 17:39:49 +02:00
|
|
|
nixpkgs = inputs.nixpkgs-stable;
|
2024-03-02 22:05:30 +01:00
|
|
|
config = {
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: {
|
|
|
|
config = {
|
|
|
|
dumb-init = {
|
|
|
|
enable = true;
|
|
|
|
type.services = {};
|
|
|
|
};
|
2023-06-13 23:05:53 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
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;
|
|
|
|
};
|
2023-06-13 23:05:53 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
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
|
2023-06-13 23:05:53 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
set -m
|
2023-06-13 23:05:53 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
for rcfile in /mail-configuration/getmail.d/*.rc
|
|
|
|
do
|
|
|
|
filename="$(basename "''${rcfile}")"
|
|
|
|
email="''${filename%".rc"}"
|
2023-06-13 23:05:53 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
mkdir -p "/getmail.d/''${email}"
|
|
|
|
chown vmail:vmail -R "/getmail.d/''${email}"
|
2023-06-13 23:05:53 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
(
|
|
|
|
while true
|
|
|
|
do
|
|
|
|
chpst -u vmail:vmail getmail -i INBOX -n -r "$rcfile" --getmaildir "/mail-configuration/getmail.d/''${email}"
|
|
|
|
sleep 10
|
2023-06-13 23:05:53 +02:00
|
|
|
done
|
2024-03-02 22:05:30 +01:00
|
|
|
) &
|
|
|
|
done
|
2023-06-13 23:05:53 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
wait
|
|
|
|
'';
|
|
|
|
enabled = true;
|
2023-06-13 23:05:53 +02:00
|
|
|
};
|
|
|
|
};
|
2024-03-02 22:05:30 +01:00
|
|
|
};
|
2023-06-13 23:05:53 +02:00
|
|
|
};
|
|
|
|
}
|
2024-03-02 22:05:30 +01:00
|
|
|
# /usr/lib/sendmail -i -oem -f %F %T
|
2023-06-13 23:05:53 +02:00
|
|
|
|