1 { lib, pkgs, config, ... }:
3 cfg = config.myServices.databases.openldap;
5 eldiron_schemas = pkgs.callPackage ./eldiron_schemas.nix {};
9 pidfile ${cfg.pids.pid}
10 argsfile ${cfg.pids.args}
17 suffix "${cfg.baseDn}"
18 rootdn "${cfg.rootDn}"
19 include ${config.secrets.location}/ldap/password
20 directory ${cfg.dataDir}
25 syncprov-checkpoint 100 10
27 TLSCertificateFile ${config.security.acme2.certs.ldap.directory}/cert.pem
28 TLSCertificateKeyFile ${config.security.acme2.certs.ldap.directory}/key.pem
29 TLSCACertificateFile ${config.security.acme2.certs.ldap.directory}/fullchain.pem
30 TLSCACertificatePath ${pkgs.cacert.unbundled}/etc/ssl/certs/
31 #This makes openldap crash
32 #TLSCipherSuite DEFAULT
34 sasl-host kerberos.immae.eu
35 include ${config.secrets.location}/ldap/access
39 options.myServices.databases = {
41 enable = lib.mkOption {
44 description = "Whether to enable ldap";
45 type = lib.types.bool;
47 baseDn = lib.mkOption {
53 rootDn = lib.mkOption {
59 rootPw = lib.mkOption {
62 Root (Hashed) password
65 accessFile = lib.mkOption {
66 type = lib.types.path;
68 The file path that defines the access
71 dataDir = lib.mkOption {
72 type = lib.types.path;
73 default = "/var/lib/openldap";
75 The directory where Openldap stores its data.
78 socketsDir = lib.mkOption {
79 type = lib.types.path;
80 default = "/run/slapd";
82 The directory where Openldap puts sockets and pid files.
87 type = lib.types.attrsOf lib.types.path;
89 pid = "${cfg.socketsDir}/slapd.pid";
90 args = "${cfg.socketsDir}/slapd.args";
100 config = lib.mkIf cfg.enable {
103 dest = "ldap/password";
104 permissions = "0400";
107 text = "rootpw ${cfg.rootPw}";
110 dest = "ldap/access";
111 permissions = "0400";
114 text = builtins.readFile "${cfg.accessFile}";
117 users.users.openldap.extraGroups = [ "keys" ];
118 networking.firewall.allowedTCPPorts = [ 636 389 ];
120 security.acme2.certs."ldap" = config.myServices.databasesCerts // {
123 plugins = [ "fullchain.pem" "key.pem" "cert.pem" "account_key.json" "account_reg.json" ];
124 domain = "ldap.immae.eu";
126 systemctl restart openldap.service
130 services.filesWatcher.openldap = {
132 paths = [ "${config.secrets.location}/ldap/" ];
135 services.openldap = {
137 dataDir = cfg.dataDir;
138 urlList = [ "ldap://" "ldaps://" ];
139 extraConfig = ldapConfig;