2011-04-13 17:35:19 +00:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.openldap;
|
|
|
|
openldap = pkgs.openldap;
|
|
|
|
|
|
|
|
configFile = pkgs.writeText "slapd.conf" cfg.extraConfig;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2011-04-13 17:35:19 +00:00
|
|
|
services.openldap = {
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2011-04-13 17:35:19 +00:00
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "
|
|
|
|
Whether to enable the ldap server.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
default = "";
|
|
|
|
description = "
|
|
|
|
sldapd.conf configuration
|
|
|
|
";
|
|
|
|
};
|
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2011-04-13 17:35:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.openldap.enable {
|
|
|
|
|
|
|
|
environment.systemPackages = [ openldap ];
|
|
|
|
|
|
|
|
jobs.openldap =
|
|
|
|
{
|
|
|
|
description = "LDAP server";
|
|
|
|
|
|
|
|
startOn = "filesystem";
|
|
|
|
daemonType = "fork";
|
|
|
|
|
2011-04-14 09:54:46 +00:00
|
|
|
preStart =
|
|
|
|
''
|
|
|
|
mkdir -p /var/run/slapd
|
|
|
|
'';
|
2011-04-13 17:35:19 +00:00
|
|
|
exec = "${openldap}/libexec/slapd -f ${configFile}";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|