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