mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-13 05:05:29 +03:00
nixos/maddy: Add option ensureCredentials
This commit is contained in:
parent
14793416a0
commit
86a685ceb1
3 changed files with 43 additions and 5 deletions
|
@ -228,8 +228,8 @@ in {
|
|||
default = [];
|
||||
description = lib.mdDoc ''
|
||||
List of IMAP accounts which get automatically created. Note that for
|
||||
a complete setup, user credentials for these accounts are required too
|
||||
and can be created using the command `maddyctl creds`.
|
||||
a complete setup, user credentials for these accounts are required
|
||||
and can be created using the `ensureCredentials` option.
|
||||
This option does not delete accounts which are not (anymore) listed.
|
||||
'';
|
||||
example = [
|
||||
|
@ -238,6 +238,33 @@ in {
|
|||
];
|
||||
};
|
||||
|
||||
ensureCredentials = mkOption {
|
||||
default = {};
|
||||
description = lib.mdDoc ''
|
||||
List of user accounts which get automatically created if they don't
|
||||
exist yet. Note that for a complete setup, corresponding mail boxes
|
||||
have to get created using the `ensureAccounts` option.
|
||||
This option does not delete accounts which are not (anymore) listed.
|
||||
'';
|
||||
example = {
|
||||
"user1@localhost".passwordFile = /secrets/user1-localhost;
|
||||
"user2@localhost".passwordFile = /secrets/user2-localhost;
|
||||
};
|
||||
type = types.attrsOf (types.submodule {
|
||||
options = {
|
||||
passwordFile = mkOption {
|
||||
type = types.path;
|
||||
example = "/path/to/file";
|
||||
default = null;
|
||||
description = lib.mdDoc ''
|
||||
Specifies the path to a file containing the
|
||||
clear text password for the user.
|
||||
'';
|
||||
};
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -265,6 +292,13 @@ in {
|
|||
fi
|
||||
'') cfg.ensureAccounts}
|
||||
''}
|
||||
${optionalString (cfg.ensureCredentials != {}) ''
|
||||
${concatStringsSep "\n" (mapAttrsToList (name: cfg: ''
|
||||
if ! ${pkgs.maddy}/bin/maddyctl creds list | grep "${name}"; then
|
||||
${pkgs.maddy}/bin/maddyctl creds create --password $(cat ${escapeShellArg cfg.passwordFile}) ${name}
|
||||
fi
|
||||
'') cfg.ensureCredentials)}
|
||||
''}
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue