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";
|
|
|
|
version = "2.2.3";
|
|
|
|
|
|
|
|
src = pkgs.fetchurl {
|
|
|
|
url = "mirror://sourceforge/courier/courier-unicode/${version}/${name}-${version}.tar.bz2";
|
|
|
|
sha256 = "sha256-COz13JdSnOOqncqghYYHYt5jbr75aL9LbgzfqvGMev8=";
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ perl ];
|
|
|
|
};
|
|
|
|
maildrop-fixed = pkgs.maildrop.overrideAttrs (
|
|
|
|
old:
|
|
|
|
{ patches =
|
|
|
|
[ ./dont-reset-path.patch
|
|
|
|
./maildrop.configure.hack.patch
|
|
|
|
];
|
|
|
|
version = "3.0.7";
|
|
|
|
src = pkgs.fetchurl {
|
|
|
|
url = "mirror://sourceforge/courier/maildrop/3.0.7/maildrop-3.0.7.tar.bz2";
|
|
|
|
sha256 = "sha256-YFzoHDk5BEcy2uRyQhlTTl27UVyAdgvjYRkUq1wfeCU=";
|
|
|
|
};
|
|
|
|
nativeBuildInputs = with pkgs; [ pcre2 pkg-config ];
|
|
|
|
buildInputs = with pkgs; [ libidn courier-unicode ];
|
|
|
|
});
|
|
|
|
|
|
|
|
getmail6-fixed = pkgs.getmail6.overrideAttrs (
|
|
|
|
old:
|
|
|
|
{ patches =
|
|
|
|
[ ./getmail-read-exec-from-path.patch
|
|
|
|
];
|
|
|
|
}
|
|
|
|
);
|
|
|
|
in
|
|
|
|
{
|
|
|
|
shutdownOnExit = true;
|
|
|
|
script = pkgs.writeShellScript "getmail-run"
|
|
|
|
''
|
|
|
|
export PATH=${with pkgs; lib.makeBinPath [ busybox runit bash getmail6-fixed maildrop-fixed ]}:${pkgs.opensmtpd}/libexec/opensmtpd:$PATH
|
|
|
|
|
|
|
|
chown vmail:vmail -R /getmail.d
|
|
|
|
|
|
|
|
set -m
|
|
|
|
|
|
|
|
for rcfile in /getmail.d/getmail.*.rc
|
|
|
|
do
|
|
|
|
foo="$(basename "''${rcfile}")"
|
|
|
|
bar="''${foo#"getmail."}"
|
|
|
|
email="''${bar%".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 "/getmail.d/getmail.''${email}.rc" --getmaildir "/getmail.d/''${email}"
|
|
|
|
sleep 10
|
|
|
|
done
|
|
|
|
) &
|
|
|
|
done
|
|
|
|
|
|
|
|
wait
|
|
|
|
'';
|
|
|
|
enabled = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
# /usr/lib/sendmail -i -oem -f %F %T
|