Add email settings

This commit is contained in:
niten 2023-08-29 22:12:23 -07:00
parent d179f52144
commit c2513cafdc
1 changed files with 34 additions and 1 deletions

View File

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }@toplevel:
with lib; with lib;
let let
@ -6,6 +6,8 @@ let
hostname = config.instance.hostname; hostname = config.instance.hostname;
domainName = config.fudo.hosts."${hostname}".domain;
hostSecrets = config.fudo.secrets.host-secrets."${hostname}"; hostSecrets = config.fudo.secrets.host-secrets."${hostname}";
mkEnvFile = envVars: mkEnvFile = envVars:
@ -50,6 +52,27 @@ in {
}; };
}; };
smtp = {
host = mkOption {
type = str;
default = "smtp.${domainName}";
};
port = mkOption {
type = port;
default = 587;
};
user = mkOption {
type = str;
default = "authentik";
};
password-file = mkOption { type = str; };
from-address = mkOption {
type = str;
default =
"${toplevel.config.services.authentikContainer.smtp.user}@${domainName}";
};
};
uids = { uids = {
authentik = mkOption { authentik = mkOption {
type = int; type = int;
@ -103,11 +126,21 @@ in {
authentikEnv = { authentikEnv = {
source-file = mkEnvFile { source-file = mkEnvFile {
AUTHENTIK_REDIS__HOST = "redis"; AUTHENTIK_REDIS__HOST = "redis";
AUTHENTIK_POSTGRESQL__HOST = "postgres"; AUTHENTIK_POSTGRESQL__HOST = "postgres";
AUTHENTIK_POSTGRESQL__NAME = "authentik"; AUTHENTIK_POSTGRESQL__NAME = "authentik";
AUTHENTIK_POSTGRESQL__USER = "authentik"; AUTHENTIK_POSTGRESQL__USER = "authentik";
AUTHENTIK_POSTGRESQL__PASSWORD = readFile postgresPasswdFile; AUTHENTIK_POSTGRESQL__PASSWORD = readFile postgresPasswdFile;
AUTHENTIK_SECRET_KEY = readFile authentikSecretKeyFile; AUTHENTIK_SECRET_KEY = readFile authentikSecretKeyFile;
AUTHENTIK_EMAIL__HOST = cfg.smtp.host;
AUTHENTIK_EMAIL__PORT = toString cfg.smtp.port;
AUTHENTIK_EMAIL__USERNAME = cfg.smtp.user;
AUTHENTIK_EMAIL__PASSWORD = readFile cfg.smtp.password-file;
AUTHENTIK_EMAIL__USE_TLS = true;
AUTHENTIK_EMAIL__TIMEOUT = 10;
AUTHENTIK_EMAIL__FROM = cfg.smtp.from-address;
}; };
target-file = "/run/authentik/authentik.env"; target-file = "/run/authentik/authentik.env";
}; };