mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-15 02:03:01 +00:00
0a37316d6c
This commit replaces a lot of usages of `mkOption` with the package type, to be `mkPackageOption`, in order to reduce the amount of code.
58 lines
1.1 KiB
Nix
58 lines
1.1 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.saslauthd;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.saslauthd = {
|
|
|
|
enable = mkEnableOption (lib.mdDoc "saslauthd, the Cyrus SASL authentication daemon");
|
|
|
|
package = mkPackageOption pkgs [ "cyrus_sasl" "bin" ] { };
|
|
|
|
mechanism = mkOption {
|
|
type = types.str;
|
|
default = "pam";
|
|
description = lib.mdDoc "Auth mechanism to use";
|
|
};
|
|
|
|
config = mkOption {
|
|
type = types.lines;
|
|
default = "";
|
|
description = lib.mdDoc "Configuration to use for Cyrus SASL authentication daemon.";
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
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";
|
|
};
|
|
};
|
|
};
|
|
}
|