at 25.11-pre 1.6 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7let 8 9 cfg = config.services.go-autoconfig; 10 format = pkgs.formats.yaml { }; 11 configFile = format.generate "config.yml" cfg.settings; 12 13in 14{ 15 options = { 16 services.go-autoconfig = { 17 18 enable = lib.mkEnableOption "IMAP/SMTP autodiscover feature for mail clients"; 19 20 settings = lib.mkOption { 21 default = { }; 22 description = '' 23 Configuration for go-autoconfig. See 24 <https://github.com/L11R/go-autoconfig/blob/master/config.yml> 25 for more information. 26 ''; 27 type = lib.types.submodule { 28 freeformType = format.type; 29 }; 30 example = lib.literalExpression '' 31 { 32 service_addr = ":1323"; 33 domain = "autoconfig.example.org"; 34 imap = { 35 server = "example.org"; 36 port = 993; 37 }; 38 smtp = { 39 server = "example.org"; 40 port = 465; 41 }; 42 } 43 ''; 44 }; 45 46 }; 47 }; 48 49 config = lib.mkIf cfg.enable { 50 51 systemd = { 52 services.go-autoconfig = { 53 wantedBy = [ "multi-user.target" ]; 54 description = "IMAP/SMTP autodiscover server"; 55 after = [ "network.target" ]; 56 serviceConfig = { 57 ExecStart = "${pkgs.go-autoconfig}/bin/go-autoconfig -config ${configFile}"; 58 Restart = "on-failure"; 59 WorkingDirectory = ''${pkgs.go-autoconfig}/''; 60 DynamicUser = true; 61 }; 62 }; 63 }; 64 65 }; 66 67 meta.maintainers = with lib.maintainers; [ onny ]; 68 69}