]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/databases/openldap/default.nix
Move secrets to flakes
[perso/Immae/Config/Nix.git] / modules / private / databases / openldap / default.nix
index 22f6f7b3de3b8b5d9223b6034b3a203c32cc6a1d..f4851b5f885a09d3d98ff6994526619b873f2897 100644 (file)
@@ -12,27 +12,14 @@ let
     moduleload      back_hdb
     backend         hdb
 
-    moduleload      memberof
-    database        hdb
-    suffix          "${cfg.baseDn}"
-    rootdn          "${cfg.rootDn}"
-    include         ${config.secrets.location}/ldap/password
-    directory       ${cfg.dataDir}
-    overlay         memberof
-
-    moduleload      syncprov
-    overlay         syncprov
-    syncprov-checkpoint 100 10
-
-    TLSCertificateFile    ${config.security.acme.directory}/ldap/cert.pem
-    TLSCertificateKeyFile ${config.security.acme.directory}/ldap/key.pem
-    TLSCACertificateFile  ${config.security.acme.directory}/ldap/fullchain.pem
+    TLSCertificateFile    ${config.security.acme.certs.ldap.directory}/cert.pem
+    TLSCertificateKeyFile ${config.security.acme.certs.ldap.directory}/key.pem
+    TLSCACertificateFile  ${config.security.acme.certs.ldap.directory}/fullchain.pem
     TLSCACertificatePath  ${pkgs.cacert.unbundled}/etc/ssl/certs/
     #This makes openldap crash
     #TLSCipherSuite        DEFAULT
 
     sasl-host kerberos.immae.eu
-    include ${config.secrets.location}/ldap/access
     '';
 in
 {
@@ -111,7 +98,14 @@ in
         permissions = "0400";
         user = "openldap";
         group = "openldap";
-        text = builtins.readFile "${cfg.accessFile}";
+        text = builtins.readFile cfg.accessFile;
+      }
+      {
+        dest = "ldap";
+        permissions = "0500";
+        user = "openldap";
+        group = "openldap";
+        isDir = true;
       }
     ];
     users.users.openldap.extraGroups = [ "keys" ];
@@ -120,7 +114,6 @@ in
     security.acme.certs."ldap" = config.myServices.databasesCerts // {
       user = "openldap";
       group = "openldap";
-      plugins = [ "fullchain.pem" "key.pem" "cert.pem" "account_key.json" ];
       domain = "ldap.immae.eu";
       postRun = ''
         systemctl restart openldap.service
@@ -129,14 +122,29 @@ in
 
     services.filesWatcher.openldap = {
       restart = true;
-      paths = [ "${config.secrets.location}/ldap/" ];
+      paths = [ config.secrets.fullPaths."ldap" ];
     };
 
     services.openldap = {
       enable = true;
       dataDir = cfg.dataDir;
       urlList = [ "ldap://" "ldaps://" ];
+      logLevel = "none";
       extraConfig = ldapConfig;
+      extraDatabaseConfig = ''
+        moduleload      memberof
+        overlay         memberof
+
+        moduleload      syncprov
+        overlay         syncprov
+        syncprov-checkpoint 100 10
+
+        include ${config.secrets.fullPaths."ldap/access"}
+        '';
+      rootpwFile = config.secrets.fullPaths."ldap/password";
+      suffix = cfg.baseDn;
+      rootdn = cfg.rootDn;
+      database = "hdb";
     };
   };
 }