mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 19:55:41 +03:00
nixos/maddy: add package option
This commit is contained in:
parent
250b695f41
commit
baf2d3e27f
1 changed files with 9 additions and 7 deletions
|
@ -143,6 +143,8 @@ in
|
|||
|
||||
enable = lib.mkEnableOption "Maddy, a free an open source mail server";
|
||||
|
||||
package = lib.mkPackageOption pkgs "maddy" { };
|
||||
|
||||
user = lib.mkOption {
|
||||
default = "maddy";
|
||||
type = with lib.types; uniq str;
|
||||
|
@ -386,7 +388,7 @@ in
|
|||
|
||||
systemd = {
|
||||
|
||||
packages = [ pkgs.maddy ];
|
||||
packages = [ cfg.package ];
|
||||
services = {
|
||||
maddy = {
|
||||
serviceConfig = {
|
||||
|
@ -402,16 +404,16 @@ in
|
|||
script = ''
|
||||
${lib.optionalString (cfg.ensureAccounts != [ ]) ''
|
||||
${lib.concatMapStrings (account: ''
|
||||
if ! ${pkgs.maddy}/bin/maddyctl imap-acct list | grep "${account}"; then
|
||||
${pkgs.maddy}/bin/maddyctl imap-acct create ${account}
|
||||
if ! ${cfg.package}/bin/maddyctl imap-acct list | grep "${account}"; then
|
||||
${cfg.package}/bin/maddyctl imap-acct create ${account}
|
||||
fi
|
||||
'') cfg.ensureAccounts}
|
||||
''}
|
||||
${lib.optionalString (cfg.ensureCredentials != { }) ''
|
||||
${lib.concatStringsSep "\n" (
|
||||
lib.mapAttrsToList (name: cfg: ''
|
||||
if ! ${pkgs.maddy}/bin/maddyctl creds list | grep "${name}"; then
|
||||
${pkgs.maddy}/bin/maddyctl creds create --password $(cat ${lib.escapeShellArg cfg.passwordFile}) ${name}
|
||||
lib.mapAttrsToList (name: credentials: ''
|
||||
if ! ${cfg.package}/bin/maddyctl creds list | grep "${name}"; then
|
||||
${cfg.package}/bin/maddyctl creds create --password $(cat ${lib.escapeShellArg credentials.passwordFile}) ${name}
|
||||
fi
|
||||
'') cfg.ensureCredentials
|
||||
)}
|
||||
|
@ -486,7 +488,7 @@ in
|
|||
};
|
||||
|
||||
environment.systemPackages = [
|
||||
pkgs.maddy
|
||||
cfg.package
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue