1 { pkgs, lib, domain, domainSuffix, domainGroup }:
3 inherit (pkgs.lib) unlines;
7 , gidNumber ? uidNumber
10 , userPassword ? null # Use slappasswd -o module-load=pw-pbkdf2 -h "{PBKDF2-SHA256}"
13 , mailHomeDirectory ? null
14 , mailStorageDirectory ? null
15 , loginShell ? "/run/current-system/sw/bin/bash"
17 , mailForwardingAddress ? []
18 , mailGroupMember ? domainGroup
21 "\n" + lib.concatStringsSep "\n\n" [
23 dn: uid=${uid},ou=accounts,ou=posix,${domainSuffix}
25 objectClass: posixAccount
26 objectClass: shadowAccount
27 objectClass: PostfixBookMailAccount
28 objectClass: PostfixBookMailForward
31 mail: ${uid}@${domain}
32 mailEnabled: ${if mailEnabled then "TRUE" else "FALSE"}
33 mailGroupMember: ${mailGroupMember}''
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
49 dn: cn=${uid},ou=groups,ou=posix,${domainSuffix}
51 objectClass: posixGroup
52 gidNumber: ${toString gidNumber}