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 , mailStorageDirectory ? null
14 , loginShell ? "/run/current-system/sw/bin/bash"
16 , mailForwardingAddress ? []
18 "\n" + lib.concatStringsSep "\n\n" [
20 dn: uid=${uid},ou=accounts,ou=posix,${domainSuffix}
22 objectClass: posixAccount
23 objectClass: shadowAccount
24 objectClass: PostfixBookMailAccount
25 objectClass: PostfixBookMailForward
28 mail: ${uid}@${domain}
29 mailEnabled: ${if mailEnabled then "TRUE" else "FALSE"}
30 mailGroupMember: ${domainGroup}''
32 ++ [ "uidNumber: ${toString uidNumber}" ]
33 ++ [ "gidNumber: ${toString gidNumber}" ]
34 ++ [ "homeDirectory: ${homeDirectory}" ]
35 ++ lib.optional (loginShell != null) "loginShell: ${loginShell}"
36 ++ lib.optional (userPassword != null) "userPassword: ${userPassword}"
37 ++ lib.optional (mailStorageDirectory != null) "mailStorageDirectory: ${mailStorageDirectory}"
38 ++ map (forward: "mailForwardingAddress: ${forward}") mailForwardingAddress
39 ++ map (alias: "mailAlias: ${alias}@${domain}") mailAlias
40 ++ lib.optional (mailAlias == []) "mailAlias:"
41 # mailAlias is required by PostfixBookMailForward
44 dn: cn=${uid},ou=groups,ou=posix,${domainSuffix}
46 objectClass: posixGroup
47 gidNumber: ${toString gidNumber}