1 { config, lib, pkgs, ... }:
5 cfg = config.services.dkimproxy-out;
6 keydir = "/var/lib/dkimproxy-out";
7 privkey = "${keydir}/private.key";
8 pubkey = "${keydir}/public.key";
13 services.dkimproxy-out = {
19 Whether to enable dkimproxy_out.
21 Note that a key will be auto-generated, and can be found in
28 example = "127.0.0.1:10027";
29 description = lib.mdDoc "Address:port DKIMproxy should listen on.";
34 example = "127.0.0.1:10028";
35 description = lib.mdDoc "Address:port DKIMproxy should forward mail to.";
39 type = with types; listOf str;
40 example = [ "example.org" "example.com" ];
41 description = lib.mdDoc "List of domains DKIMproxy can sign for.";
46 example = "selector1";
49 The selector to use for DKIM key identification.
51 For example, if 'selector1' is used here, then for each domain
52 'example.org' given in `domain`, 'selector1._domainkey.example.org'
53 should contain the TXT record indicating the public key is the one
54 in ${pubkey}: "v=DKIM1; t=s; p=[THE PUBLIC KEY]".
63 Size of the RSA key to use to sign outgoing emails. Note that the
64 maximum mandatorily verified as per RFC6376 is 2048.
68 # TODO: allow signature for other schemes than dkim(c=relaxed/relaxed)?
69 # This being the scheme used by gmail, maybe nothing more is needed for
76 configfile = pkgs.writeText "dkimproxy_out.conf"
81 domain ${concatStringsSep "," cfg.domains}
82 selector ${cfg.selector}
84 signature dkim(c=relaxed/relaxed)
90 users.groups.dkimproxy-out = {};
91 users.users.dkimproxy-out = {
92 description = "DKIMproxy_out daemon";
93 group = "dkimproxy-out";
97 systemd.services.dkimproxy-out = {
98 description = "DKIMproxy_out";
99 wantedBy = [ "multi-user.target" ];
101 if [ ! -d "${keydir}" ]; then
103 chmod 0700 "${keydir}"
104 ${pkgs.openssl}/bin/openssl genrsa -out "${privkey}" ${toString cfg.keySize}
105 ${pkgs.openssl}/bin/openssl rsa -in "${privkey}" -pubout -out "${pubkey}"
106 chown -R dkimproxy-out:dkimproxy-out "${keydir}"
110 exec ${pkgs.dkimproxy}/bin/dkimproxy.out --conf_file=${configfile}
113 User = "dkimproxy-out";
114 PermissionsStartOnly = true;
119 meta.maintainers = with lib.maintainers; [ ekleog ];