]> Untitled Git - MarigoldOS/.git/blob - modules/yggmail.nix
Port some stuff from 0x00 repo.
[MarigoldOS/.git] / modules / yggmail.nix
1 { config, pkgs, lib, ... }:
2 with lib;
3 let
4   cfg = config.services.yggmail;
5 in {
6   options.services.yggmail = {
7     enable = mkEnableOption "yggmail mailserver";
8
9     peer = mkOption {
10       #default = "";
11       type = types.str; 
12       default = "tcp://127.0.0.1:6893";
13       example = "tcp://127.0.0.1:6893";
14       description = ''
15         Connect to a specific Yggdrasil static peer
16       '';
17     };
18
19     listenAddress = mkOption {
20       default = "localhost";
21       example = "127.0.0.1";
22       type = types.str;
23       description = ''
24         Interface address to listen on
25       '';
26     };
27
28     imapPort = mkOption {
29       default = "localhost:1143";
30       example = "localhost:1143";
31       type = types.port;
32       description = ''
33         Listen port for IMAP
34       '';
35     };
36
37     smtpPort = mkOption {
38       default = "localhost:1025";
39       example = "localhost:1025";
40       type = types.port;
41       description = ''
42         Listen port for SMTP
43       '';
44     };
45   };
46   config = mkIf cfg.enable {
47     systemd.services.yggmail = {
48       wantedBy = [ "multi-user.target" ];
49       after = [ "network.target" ];
50       description = "Start the yggmail daemon.";
51       serviceConfig = {
52         DynamicUser = true;
53         #AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ];
54         #CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ];
55         ExecStart = ''${pkgs.nur.yggmail}/bin/yggmail -imap=${cfg.listenAddress}:${toString cfg.imapPort} -smtp=${cfg.listenAddress}:${toString cfg.smtpPort} -peer=${cfg.peer}'';
56         Restart = "always";
57         StateDirectory = "yggmail";
58         WorkingDirectory = "/var/lib/yggmail";
59       };
60     };
61   };
62 }
63