]> Git — Sourcephile - sourcephile-nix.git/blob - servers/mermet/openldap/posixAccount.nix
sanoid: update upstream fix
[sourcephile-nix.git] / servers / mermet / openldap / posixAccount.nix
1 { pkgs, lib, domain, domainSuffix, domainGroup }:
2 let
3 inherit (pkgs.lib) unlines;
4 in
5 { uid
6 , uidNumber
7 , gidNumber ? uidNumber
8 , cn ? ""
9 , sn ? ""
10 , userPassword ? null # Use slappasswd -o module-load=pw-pbkdf2 -h "{PBKDF2-SHA256}"
11 , mailAlias ? []
12 , homeDirectory ? ""
13 , mailStorageDirectory ? null
14 , loginShell ? "/run/current-system/sw/bin/bash"
15 , mailEnabled ? true
16 , mailForwardingAddress ? []
17 , mailGroupMember ? domainGroup
18 }:
19 "\n" + lib.concatStringsSep "\n\n" [
20 (unlines ([ ''
21 dn: uid=${uid},ou=accounts,ou=posix,${domainSuffix}
22 objectClass: person
23 objectClass: posixAccount
24 objectClass: shadowAccount
25 objectClass: PostfixBookMailAccount
26 objectClass: PostfixBookMailForward
27 cn: ${cn}
28 sn: ${sn}
29 mail: ${uid}@${domain}
30 mailEnabled: ${if mailEnabled then "TRUE" else "FALSE"}
31 mailGroupMember: ${mailGroupMember}''
32 ]
33 ++ [ "uidNumber: ${toString uidNumber}" ]
34 ++ [ "gidNumber: ${toString gidNumber}" ]
35 ++ [ "homeDirectory: ${homeDirectory}" ]
36 ++ lib.optional (loginShell != null) "loginShell: ${loginShell}"
37 ++ lib.optional (userPassword != null) "userPassword: ${userPassword}"
38 ++ lib.optional (mailStorageDirectory != null) "mailStorageDirectory: ${mailStorageDirectory}"
39 ++ map (forward: "mailForwardingAddress: ${forward}") mailForwardingAddress
40 ++ map (alias: "mailAlias: ${alias}@${domain}") mailAlias
41 ++ lib.optional (mailAlias == []) "mailAlias:"
42 # mailAlias is required by PostfixBookMailForward
43 ))
44 ''
45 dn: cn=${uid},ou=groups,ou=posix,${domainSuffix}
46 objectClass: top
47 objectClass: posixGroup
48 gidNumber: ${toString gidNumber}
49 memberUid: ${uid}
50 ''
51 ]