]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/databases/openldap/default.nix
Remove direct dependency to myconfig in database modules
[perso/Immae/Config/Nix.git] / modules / private / databases / openldap / default.nix
index 46f85d26f0ca6f1da3358690ee5eee78334e97cb..e048d565200f532eaddfa6c4ab8eb7ce3112254e 100644 (file)
@@ -1,4 +1,4 @@
-{ lib, pkgs, config, myconfig,  ... }:
+{ lib, pkgs, config, ... }:
 let
   cfg = config.myServices.databases.openldap;
   ldapConfig = let
@@ -27,8 +27,8 @@ let
 
     moduleload      memberof
     database        hdb
-    suffix          "${myconfig.env.ldap.base}"
-    rootdn          "${myconfig.env.ldap.root_dn}"
+    suffix          "${cfg.baseDn}"
+    rootdn          "${cfg.rootDn}"
     include         ${config.secrets.location}/ldap/password
     directory       ${cfg.dataDir}
     overlay         memberof
@@ -53,6 +53,30 @@ in
         description = "Whether to enable ldap";
         type = lib.types.bool;
       };
+      baseDn = lib.mkOption {
+        type = lib.types.str;
+        description = ''
+          Base DN for LDAP
+        '';
+      };
+      rootDn = lib.mkOption {
+        type = lib.types.str;
+        description = ''
+          Root DN
+        '';
+      };
+      rootPw = lib.mkOption {
+        type = lib.types.str;
+        description = ''
+          Root (Hashed) password
+        '';
+      };
+      accessFile = lib.mkOption {
+        type = lib.types.path;
+        description = ''
+          The file path that defines the access
+        '';
+      };
       dataDir = lib.mkOption {
         type = lib.types.path;
         default = "/var/lib/openldap";
@@ -89,14 +113,14 @@ in
         permissions = "0400";
         user = "openldap";
         group = "openldap";
-        text = "rootpw          ${myconfig.env.ldap.root_pw}";
+        text = "rootpw          ${cfg.rootPw}";
       }
       {
-        dest = "ldap/access ";
+        dest = "ldap/access";
         permissions = "0400";
         user = "openldap";
         group = "openldap";
-        text = builtins.readFile "${myconfig.privateFiles}/ldap.conf";
+        text = builtins.readFile "${cfg.accessFile}";
       }
     ];
     users.users.openldap.extraGroups = [ "keys" ];