mirror of
https://gitlab.com/simple-nixos-mailserver/nixos-mailserver.git
synced 2025-04-02 05:44:33 +05:00
Merge branch 'dev/user-maildir' into 'master'
Support customized maildir type and location per virtual user See merge request simple-nixos-mailserver/nixos-mailserver!347
This commit is contained in:
commit
035c6891a6
54
default.nix
54
default.nix
@ -140,6 +140,60 @@ in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
customMaildir = mkOption {
|
||||||
|
type = types.nullOr (types.submodule ({ name, ...}: {
|
||||||
|
options = {
|
||||||
|
uid = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
example = 1000;
|
||||||
|
description = ''
|
||||||
|
User ID for files and directories in the maildir. Files and
|
||||||
|
directories created by Dovecot will be assigned this UID.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
gid = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
example = 1000;
|
||||||
|
description = ''
|
||||||
|
Group ID for files and directories in the maildir. Files and
|
||||||
|
directories created by Dovecot will be assigned this GID.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
dovecotHome = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
example = "/home/myusername";
|
||||||
|
description = ''
|
||||||
|
Home directory for Dovecot virtual user. This is used to
|
||||||
|
maintain mail user's private state. This MUST be different
|
||||||
|
for each Dovecot virtual user and MUST be an absolute path.
|
||||||
|
Refer to the Dovecot documentation for further information
|
||||||
|
on this configuration option:
|
||||||
|
https://wiki.dovecot.org/VirtualUsers/Home
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
mailDirectorySpec = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
example = "maildir:~/mail";
|
||||||
|
description = ''
|
||||||
|
Dovecot mail location specification. Refer to the Dovecot
|
||||||
|
documentation for further information on this configuration
|
||||||
|
option:
|
||||||
|
https://doc.dovecot.org/configuration_manual/mail_location/
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
Configuration options for a custom Maildir location. For instance,
|
||||||
|
this can be used to implement home-directory Maildirs for specific
|
||||||
|
users only. If null, a Maildir under /var/vmail will be assigned.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
sieveScript = mkOption {
|
sieveScript = mkOption {
|
||||||
type = with types; nullOr lines;
|
type = with types; nullOr lines;
|
||||||
default = null;
|
default = null;
|
||||||
|
@ -123,12 +123,24 @@ let
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat <<EOF > ${userdbFile}
|
cat <<EOF > ${userdbFile}
|
||||||
${lib.concatStringsSep "\n" (lib.mapAttrsToList (name: value:
|
${lib.concatStringsSep "\n" (lib.mapAttrsToList (name: value: (
|
||||||
"${name}:::::::"
|
if value.customMaildir == null then (
|
||||||
+ (if lib.isString value.quota
|
"${name}:::::::"
|
||||||
then "userdb_quota_rule=*:storage=${value.quota}"
|
) else (
|
||||||
else "")
|
"${name}:"
|
||||||
) cfg.loginAccounts)}
|
+ ":${builtins.toString value.customMaildir.uid}"
|
||||||
|
+ ":${builtins.toString value.customMaildir.gid}"
|
||||||
|
+ ":"
|
||||||
|
+ ":${value.customMaildir.dovecotHome}"
|
||||||
|
+ ":/run/current-system/sw/bin/nologin"
|
||||||
|
+ ":userdb_mail=${value.customMaildir.mailDirectorySpec}"
|
||||||
|
)
|
||||||
|
) + (
|
||||||
|
if lib.isString value.quota then
|
||||||
|
" userdb_quota_rule=*:storage=${value.quota}"
|
||||||
|
else
|
||||||
|
""
|
||||||
|
)) cfg.loginAccounts)}
|
||||||
EOF
|
EOF
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user