1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.services.mail.freepopsd;
7in
8
9{
10 options = {
11 services.mail.freepopsd = {
12 enable = mkOption {
13 default = false;
14 type = with types; bool;
15 description = ''
16 Enables Freepops, a POP3 webmail wrapper.
17 '';
18 };
19
20 port = mkOption {
21 default = 2000;
22 type = with types; uniq int;
23 description = ''
24 Port on which the pop server will listen.
25 '';
26 };
27
28 threads = mkOption {
29 default = 5;
30 type = with types; uniq int;
31 description = ''
32 Max simultaneous connections.
33 '';
34 };
35
36 bind = mkOption {
37 default = "0.0.0.0";
38 type = types.str;
39 description = ''
40 Bind over an IPv4 address instead of any.
41 '';
42 };
43
44 logFile = mkOption {
45 default = "/var/log/freepopsd";
46 example = "syslog";
47 type = types.str;
48 description = ''
49 Filename of the log file or syslog to rely on the logging daemon.
50 '';
51 };
52
53 suid = {
54 user = mkOption {
55 default = "nobody";
56 type = types.str;
57 description = ''
58 User name under which freepopsd will be after binding the port.
59 '';
60 };
61
62 group = mkOption {
63 default = "nogroup";
64 type = types.str;
65 description = ''
66 Group under which freepopsd will be after binding the port.
67 '';
68 };
69 };
70
71 };
72 };
73
74 config = mkIf cfg.enable {
75 systemd.services.freepopsd = {
76 description = "Freepopsd (webmail over POP3)";
77 wantedBy = [ "ip-up.target" ];
78 script = ''
79 ${pkgs.freepops}/bin/freepopsd \
80 -p ${toString cfg.port} \
81 -t ${toString cfg.threads} \
82 -b ${cfg.bind} \
83 -vv -l ${cfg.logFile} \
84 -s ${cfg.suid.user}.${cfg.suid.group}
85 '';
86 };
87 };
88}