X-Git-Url: https://git.kernelpanic.cafe/?p=MarigoldOS%2F.git;a=blobdiff_plain;f=modules%2Fyggmail.nix;fp=modules%2Fyggmail.nix;h=5bf99c34c6cda9b72df1608681a1621e7b6b41b5;hp=0000000000000000000000000000000000000000;hb=5be69113d25ab18f3381be6cc38f60bef8b687b2;hpb=754832f815bda4c941af3e7d27a5886a17dc6043 diff --git a/modules/yggmail.nix b/modules/yggmail.nix new file mode 100644 index 0000000..5bf99c3 --- /dev/null +++ b/modules/yggmail.nix @@ -0,0 +1,63 @@ +{ config, pkgs, lib, ... }: +with lib; +let + cfg = config.services.yggmail; +in { + options.services.yggmail = { + enable = mkEnableOption "yggmail mailserver"; + + peer = mkOption { + #default = ""; + type = types.str; + default = "tcp://127.0.0.1:6893"; + example = "tcp://127.0.0.1:6893"; + description = '' + Connect to a specific Yggdrasil static peer + ''; + }; + + listenAddress = mkOption { + default = "localhost"; + example = "127.0.0.1"; + type = types.str; + description = '' + Interface address to listen on + ''; + }; + + imapPort = mkOption { + default = "localhost:1143"; + example = "localhost:1143"; + type = types.port; + description = '' + Listen port for IMAP + ''; + }; + + smtpPort = mkOption { + default = "localhost:1025"; + example = "localhost:1025"; + type = types.port; + description = '' + Listen port for SMTP + ''; + }; + }; + config = mkIf cfg.enable { + systemd.services.yggmail = { + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + description = "Start the yggmail daemon."; + serviceConfig = { + DynamicUser = true; + #AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ]; + #CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ]; + ExecStart = ''${pkgs.nur.yggmail}/bin/yggmail -imap=${cfg.listenAddress}:${toString cfg.imapPort} -smtp=${cfg.listenAddress}:${toString cfg.smtpPort} -peer=${cfg.peer}''; + Restart = "always"; + StateDirectory = "yggmail"; + WorkingDirectory = "/var/lib/yggmail"; + }; + }; + }; +} +