mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-12-01 20:46:12 +01:00
80 lines
2.1 KiB
Nix
80 lines
2.1 KiB
Nix
|
{ inputs, config, ... }:
|
||
|
let
|
||
|
config' = config;
|
||
|
in
|
||
|
{
|
||
|
flake.nixngConfigurations.getmail = inputs.nixng.nglib.makeSystem {
|
||
|
system = "x86_64-linux";
|
||
|
name = "ra-systems-getmail";
|
||
|
inherit (inputs)
|
||
|
nixpkgs;
|
||
|
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
|