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