2015-12-24 19:34:43 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.pfix-srsd = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Whether to run the postfix sender rewriting scheme daemon.";
|
2015-12-24 19:34:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
domain = mkOption {
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "The domain for which to enable srs";
|
2015-12-24 19:34:43 +00:00
|
|
|
type = types.str;
|
|
|
|
example = "example.com";
|
|
|
|
};
|
|
|
|
|
|
|
|
secretsFile = mkOption {
|
2022-08-30 13:18:54 +01:00
|
|
|
description = lib.mdDoc ''
|
2015-12-24 19:34:43 +00:00
|
|
|
The secret data used to encode the SRS address.
|
|
|
|
to generate, use a command like:
|
2022-08-30 13:18:54 +01:00
|
|
|
`for n in $(seq 5); do dd if=/dev/urandom count=1 bs=1024 status=none | sha256sum | sed 's/ -$//' | sed 's/^/ /'; done`
|
2015-12-24 19:34:43 +00:00
|
|
|
'';
|
|
|
|
type = types.path;
|
|
|
|
default = "/var/lib/pfix-srsd/secrets";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.pfix-srsd.enable {
|
|
|
|
environment = {
|
|
|
|
systemPackages = [ pkgs.pfixtools ];
|
|
|
|
};
|
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
systemd.services.pfix-srsd = {
|
2015-12-24 19:34:43 +00:00
|
|
|
description = "Postfix sender rewriting scheme daemon";
|
|
|
|
before = [ "postfix.service" ];
|
|
|
|
#note that we use requires rather than wants because postfix
|
|
|
|
#is unable to process (almost) all mail without srsd
|
|
|
|
requiredBy = [ "postfix.service" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "forking";
|
2018-12-19 21:37:00 +00:00
|
|
|
PIDFile = "/run/pfix-srsd.pid";
|
|
|
|
ExecStart = "${pkgs.pfixtools}/bin/pfix-srsd -p /run/pfix-srsd.pid -I ${config.services.pfix-srsd.domain} ${config.services.pfix-srsd.secretsFile}";
|
2015-12-24 19:34:43 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2020-08-08 01:54:16 +01:00
|
|
|
}
|