1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7let
8
9 cfg = config.services.saslauthd;
10
11in
12
13{
14
15 ###### interface
16
17 options = {
18
19 services.saslauthd = {
20
21 enable = lib.mkEnableOption "saslauthd, the Cyrus SASL authentication daemon";
22
23 package = lib.mkPackageOption pkgs [ "cyrus_sasl" "bin" ] { };
24
25 mechanism = lib.mkOption {
26 type = lib.types.str;
27 default = "pam";
28 description = "Auth mechanism to use";
29 };
30
31 config = lib.mkOption {
32 type = lib.types.lines;
33 default = "";
34 description = "Configuration to use for Cyrus SASL authentication daemon.";
35 };
36
37 };
38
39 };
40
41 ###### implementation
42
43 config = lib.mkIf cfg.enable {
44
45 systemd.services.saslauthd = {
46 description = "Cyrus SASL authentication daemon";
47
48 wantedBy = [ "multi-user.target" ];
49
50 serviceConfig = {
51 ExecStart = "@${cfg.package}/sbin/saslauthd saslauthd -a ${cfg.mechanism} -O ${pkgs.writeText "saslauthd.conf" cfg.config}";
52 Type = "forking";
53 PIDFile = "/run/saslauthd/saslauthd.pid";
54 Restart = "always";
55 };
56 };
57 };
58}