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 ];
|
|
|
|
|
2013-04-09 15:50:53 +00:00
|
|
|
systemd.services.openldap = {
|
|
|
|
description = "LDAP server";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
preStart = ''
|
|
|
|
mkdir -p /var/run/slapd
|
|
|
|
'';
|
|
|
|
serviceConfig.ExecStart = "${openldap}/libexec/slapd -d 0 -f ${configFile}";
|
|
|
|
};
|
2011-04-13 17:35:19 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|