]> Git — Sourcephile - sourcephile-nix.git/blob - machines/mermet/openldap/posixAccount.nix
hydra: no longer needed
[sourcephile-nix.git] / machines / 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 , mailHomeDirectory ? null
14 , mailStorageDirectory ? null
15 , loginShell ? "/run/current-system/sw/bin/bash"
16 , mailEnabled ? true
17 , mailForwardingAddress ? []
18 , mailGroupMember ? domainGroup
19 }:
20 "\n" + lib.concatStringsSep "\n\n" [
21 (unlines ([ ''
22 dn: uid=${uid},ou=accounts,ou=posix,${domainSuffix}
23 objectClass: person
24 objectClass: posixAccount
25 objectClass: shadowAccount
26 objectClass: PostfixBookMailAccount
27 objectClass: PostfixBookMailForward
28 cn: ${cn}
29 sn: ${sn}
30 mail: ${uid}@${domain}
31 mailEnabled: ${if mailEnabled then "TRUE" else "FALSE"}
32 mailGroupMember: ${mailGroupMember}''
33 ]
34 ++ [ "uidNumber: ${toString uidNumber}" ]
35 ++ [ "gidNumber: ${toString gidNumber}" ]
36 ++ [ "homeDirectory: ${homeDirectory}" ]
37 ++ lib.optional (loginShell != null) "loginShell: ${loginShell}"
38 ++ lib.optional (userPassword != null) "userPassword: ${userPassword}"
39 ++ lib.optional (mailHomeDirectory != null) "mailHomeDirectory: ${mailHomeDirectory}"
40 ++ lib.optional (mailStorageDirectory != null) "mailStorageDirectory: ${mailStorageDirectory}"
41 ++ map (forward: "mailForwardingAddress: ${forward}") mailForwardingAddress
42 ++ map (alias: "mailAlias: ${alias}@${domain}") mailAlias
43 ++ lib.optional (mailAlias == []) "mailAlias:"
44 # mailAlias is required by PostfixBookMailForward
45 ))
46 ''
47 dn: cn=${uid},ou=groups,ou=posix,${domainSuffix}
48 objectClass: top
49 objectClass: posixGroup
50 gidNumber: ${toString gidNumber}
51 memberUid: ${uid}
52 ''
53 ]