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" [
24 dn: uid=${uid},ou=accounts,ou=posix,${domainSuffix}
26 objectClass: posixAccount
27 objectClass: shadowAccount
28 objectClass: PostfixBookMailAccount
29 objectClass: PostfixBookMailForward
32 mail: ${uid}@${domain}
33 mailEnabled: ${if mailEnabled then "TRUE" else "FALSE"}
34 mailGroupMember: ${mailGroupMember}''
36 ++ [ "uidNumber: ${toString uidNumber}" ]
37 ++ [ "gidNumber: ${toString gidNumber}" ]
38 ++ [ "homeDirectory: ${homeDirectory}" ]
39 ++ lib.optional (loginShell != null) "loginShell: ${loginShell}"
40 ++ lib.optional (userPassword != null) "userPassword: ${userPassword}"
41 ++ lib.optional (mailHomeDirectory != null) "mailHomeDirectory: ${mailHomeDirectory}"
42 ++ lib.optional (mailStorageDirectory != null) "mailStorageDirectory: ${mailStorageDirectory}"
43 ++ lib.optional (mailQuota != null) "mailQuota: ${mailQuota}"
44 ++ map (forward: "mailForwardingAddress: ${forward}") mailForwardingAddress
45 ++ map (alias: "mailAlias: ${alias}@${domain}") mailAlias
46 ++ lib.optional (mailAlias == [ ]) "mailAlias:"
47 # mailAlias is required by PostfixBookMailForward
50 dn: cn=${uid},ou=groups,ou=posix,${domainSuffix}
52 objectClass: posixGroup
53 gidNumber: ${toString gidNumber}