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
20 "\n" + lib.concatStringsSep "\n\n" [
22 dn: uid=${uid},ou=accounts,ou=posix,${domainSuffix}
24 objectClass: posixAccount
25 objectClass: shadowAccount
26 objectClass: PostfixBookMailAccount
27 objectClass: PostfixBookMailForward
30 mail: ${uid}@${domain}
31 mailEnabled: ${if mailEnabled then "TRUE" else "FALSE"}
32 mailGroupMember: ${mailGroupMember}''
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
47 dn: cn=${uid},ou=groups,ou=posix,${domainSuffix}
49 objectClass: posixGroup
50 gidNumber: ${toString gidNumber}