{ nglib, nixpkgs }: 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.6"; src = pkgs.fetchurl { url = "mirror://sourceforge/courier/courier-unicode/${version}/${name}-${version}.tar.bz2"; sha256 = "sha256-UT9oBm7RkqzmMPYBmExWW1wdHIHZjGR46+Tts6Fb4Do="; }; nativeBuildInputs = [ perl ]; }; maildrop-fixed = pkgs.maildrop.overrideAttrs ( old: { patches = [ ./dont-reset-path.patch ./maildrop.configure.hack.patch ]; version = "3.1.5"; src = pkgs.fetchurl { url = "mirror://sourceforge/courier/maildrop/3.1.5/maildrop-3.1.5.tar.bz2"; sha256 = "sha256-Izg/s5uSaQRWRpOXSO5zfnXJ8jmU+MBnI/MEyXp42lo="; }; nativeBuildInputs = with pkgs; [ pkg-config ]; buildInputs = with pkgs; [ perl pcre2.dev libidn2.dev courier-unicode ]; configureFlags = [ "--enable-maildrop-uid=" "--enable-maildrop-gid=" ]; }); 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 [ jq busybox runit bash getmail6-fixed maildrop-fixed ]}:${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