2017-06-06 12:59:47 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.saslauthd;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.saslauthd = {
|
|
|
|
|
2024-12-29 21:50:40 +01:00
|
|
|
enable = lib.mkEnableOption "saslauthd, the Cyrus SASL authentication daemon";
|
2017-06-06 12:59:47 +02:00
|
|
|
|
2024-12-29 21:50:40 +01:00
|
|
|
package = lib.mkPackageOption pkgs [ "cyrus_sasl" "bin" ] { };
|
2017-06-06 12:59:47 +02:00
|
|
|
|
2024-12-29 21:50:40 +01:00
|
|
|
mechanism = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2017-06-06 12:59:47 +02:00
|
|
|
default = "pam";
|
|
|
|
description = "Auth mechanism to use";
|
|
|
|
};
|
|
|
|
|
2024-12-29 21:50:40 +01:00
|
|
|
config = lib.mkOption {
|
|
|
|
type = lib.types.lines;
|
2017-06-06 12:59:47 +02:00
|
|
|
default = "";
|
|
|
|
description = "Configuration to use for Cyrus SASL authentication daemon.";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2024-12-29 21:50:40 +01:00
|
|
|
config = lib.mkIf cfg.enable {
|
2017-06-06 12:59:47 +02:00
|
|
|
|
|
|
|
systemd.services.saslauthd = {
|
|
|
|
description = "Cyrus SASL authentication daemon";
|
|
|
|
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "@${cfg.package}/sbin/saslauthd saslauthd -a ${cfg.mechanism} -O ${pkgs.writeText "saslauthd.conf" cfg.config}";
|
|
|
|
Type = "forking";
|
|
|
|
PIDFile = "/run/saslauthd/saslauthd.pid";
|
|
|
|
Restart = "always";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|