]> Git — Sourcephile - sourcephile-nix.git/blob - servers/mermet/openldap.nix
nix: let shell.nix set NIX_PATH
[sourcephile-nix.git] / servers / mermet / openldap.nix
1 { pkgs, lib, config, ... }:
2 let inherit (builtins) baseNameOf readFile;
3 inherit (lib) types;
4 inherit (pkgs.lib) unlinesAttrs;
5 inherit (config) networking;
6 inherit (config.services) openldap;
7 inherit (config.users) ldap;
8 domainSuffix = "dc=" + lib.concatStringsSep ",dc=" (lib.splitString "." networking.domain);
9 in
10 {
11 imports = [
12 openldap/sourcephile.nix
13 ];
14 config = {
15 users.ldap = {
16 enable = true;
17 server = "ldapi:///";
18 base = "ou=posix,${domainSuffix}";
19 bind = {
20 #distinguishedName = "cn=admin,${domainSuffix}";
21 };
22 daemon = {
23 enable = true;
24 extraConfig = ''
25 sasl_mech EXTERNAL
26 # NOTE: nslcd cannot use SASL to bind to rootpwmoddn
27 # which is the DN used by nslcd when passwd is run by root
28 # to change the userPassword of an LDAP user.
29 # SEE: https://www.reddit.com/r/linuxadmin/comments/53sxpl/how_do_i_configure_nslcd_to_use_a_sasl_external/d7w9awd/
30 # Thus, use: ldappasswd -H ldapi:// -Y EXTERNAL uid=$SomeUID,ou=accounts,ou=posix,dc=sourcephile,dc=fr
31
32 deref never
33 log syslog debug
34 '';
35 };
36 };
37 services.openldap = {
38 enable = true;
39 dataDir = "/var/db/ldap";
40 configDir = "/var/db/slapd";
41 urlList = [ "ldapi:///" ]; # UNIX socket
42 };
43 };
44 }