2022-10-27 16:03:15 +02:00
|
|
|
{ nglib, nixpkgs }:
|
2022-04-26 09:55:22 +02:00
|
|
|
nglib.makeSystem {
|
|
|
|
system = "x86_64-linux";
|
|
|
|
name = "ra-systems-getmail";
|
|
|
|
inherit nixpkgs;
|
|
|
|
config = ({ pkgs, config, nglib, lib, ... }:
|
|
|
|
{
|
|
|
|
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 =
|
|
|
|
let
|
|
|
|
courier-unicode = with pkgs;
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
name = "courier-unicode";
|
2023-05-03 00:30:57 +02:00
|
|
|
version = "2.2.6";
|
2022-04-26 09:55:22 +02:00
|
|
|
|
|
|
|
src = pkgs.fetchurl {
|
|
|
|
url = "mirror://sourceforge/courier/courier-unicode/${version}/${name}-${version}.tar.bz2";
|
2023-05-03 00:30:57 +02:00
|
|
|
sha256 = "sha256-UT9oBm7RkqzmMPYBmExWW1wdHIHZjGR46+Tts6Fb4Do=";
|
2022-04-26 09:55:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ perl ];
|
|
|
|
};
|
|
|
|
maildrop-fixed = pkgs.maildrop.overrideAttrs (
|
|
|
|
old:
|
|
|
|
{ patches =
|
|
|
|
[ ./dont-reset-path.patch
|
|
|
|
./maildrop.configure.hack.patch
|
|
|
|
];
|
2023-05-03 00:30:57 +02:00
|
|
|
version = "3.1.5";
|
2022-04-26 09:55:22 +02:00
|
|
|
src = pkgs.fetchurl {
|
2023-05-03 00:30:57 +02:00
|
|
|
url = "mirror://sourceforge/courier/maildrop/3.1.5/maildrop-3.1.5.tar.bz2";
|
|
|
|
sha256 = "sha256-Izg/s5uSaQRWRpOXSO5zfnXJ8jmU+MBnI/MEyXp42lo=";
|
2022-04-26 09:55:22 +02:00
|
|
|
};
|
2023-05-03 00:30:57 +02:00
|
|
|
nativeBuildInputs = with pkgs; [ pkg-config ];
|
|
|
|
buildInputs = with pkgs; [ perl pcre2.dev libidn2.dev courier-unicode ];
|
|
|
|
configureFlags = [
|
|
|
|
"--enable-maildrop-uid="
|
|
|
|
"--enable-maildrop-gid="
|
|
|
|
];
|
2022-04-26 09:55:22 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
getmail6-fixed = pkgs.getmail6.overrideAttrs (
|
|
|
|
old:
|
|
|
|
{ patches =
|
|
|
|
[ ./getmail-read-exec-from-path.patch
|
|
|
|
];
|
|
|
|
}
|
|
|
|
);
|
|
|
|
in
|
|
|
|
{
|
|
|
|
shutdownOnExit = true;
|
|
|
|
script = pkgs.writeShellScript "getmail-run"
|
|
|
|
''
|
2023-02-11 23:19:07 +01:00
|
|
|
export PATH=${with pkgs; lib.makeBinPath [ jq busybox runit bash getmail6-fixed maildrop-fixed ]}:${pkgs.opensmtpd}/libexec/opensmtpd:$PATH
|
2022-04-26 09:55:22 +02:00
|
|
|
|
|
|
|
set -m
|
|
|
|
|
2023-02-11 22:48:11 +01:00
|
|
|
for rcfile in /mail-configuration/getmail.d/*.rc
|
2022-04-26 09:55:22 +02:00
|
|
|
do
|
2023-02-11 22:48:11 +01:00
|
|
|
filename="$(basename "''${rcfile}")"
|
|
|
|
email="''${filename%".rc"}"
|
2022-04-26 09:55:22 +02:00
|
|
|
|
|
|
|
mkdir -p "/getmail.d/''${email}"
|
|
|
|
chown vmail:vmail -R "/getmail.d/''${email}"
|
|
|
|
|
|
|
|
(
|
|
|
|
while true
|
|
|
|
do
|
2023-02-11 22:48:11 +01:00
|
|
|
chpst -u vmail:vmail getmail -i INBOX -n -r "$rcfile" --getmaildir "/mail-configuration/getmail.d/''${email}"
|
2022-04-26 09:55:22 +02:00
|
|
|
sleep 10
|
|
|
|
done
|
|
|
|
) &
|
|
|
|
done
|
|
|
|
|
|
|
|
wait
|
|
|
|
'';
|
|
|
|
enabled = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
# /usr/lib/sendmail -i -oem -f %F %T
|