fix mail notifications

This commit is contained in:
Lucy Hochkamp 2025-05-22 15:57:22 +02:00
parent 010951c77b
commit d7ce4d6800
No known key found for this signature in database
5 changed files with 63 additions and 24 deletions

View file

@ -13,7 +13,39 @@ in {
];
systemd.services.plausible.environment = {
IP_GEOLOCATION_DB = "${pkgs.unstable.dbip-country-lite}/share/dbip/dbip-country-lite.mmdb";
DATABASE_URL = "postgresql:///plausible?host=/run/postgresql";
};
systemd.services.plausible.script =
let cfg = config.services.plausible; in lib.mkForce ''
# Elixir does not start up if `RELEASE_COOKIE` is not set,
# even though we set `RELEASE_DISTRIBUTION=none` so the cookie should be unused.
# Thus, make a random one, which should then be ignored.
export RELEASE_COOKIE=$(tr -dc A-Za-z0-9 < /dev/urandom | head -c 20)
export ADMIN_USER_PWD="$(< $CREDENTIALS_DIRECTORY/ADMIN_USER_PWD )"
export SECRET_KEY_BASE="$(< $CREDENTIALS_DIRECTORY/SECRET_KEY_BASE )"
${lib.optionalString (
cfg.mail.smtp.passwordFile != null
) ''export SMTP_USER_PWD="$(< $CREDENTIALS_DIRECTORY/SMTP_USER_PWD )"''}
echo setup
${lib.optionalString cfg.database.postgres.setup ''
# setup
${cfg.package}/createdb.sh
''}
echo migrate
${cfg.package}/migrate.sh
export IP_GEOLOCATION_DB=${pkgs.dbip-country-lite}/share/dbip/dbip-country-lite.mmdb
# ${cfg.package}/bin/plausible eval "(Plausible.Release.prepare() ; Plausible.Auth.create_user(\"$ADMIN_USER_NAME\", \"$ADMIN_USER_EMAIL\", \"$ADMIN_USER_PWD\"))"
${lib.optionalString cfg.adminUser.activate ''
psql -d plausible <<< "UPDATE users SET email_verified=true where email = '$ADMIN_USER_EMAIL';"
''}
echo start
exec plausible start
'';
services.plausible = {
enable = true;
package = pkgs.unstable.plausible;
@ -33,11 +65,11 @@ in {
baseUrl = "https://${domain}";
secretKeybaseFile = config.age.secrets.plausibleSecretKeybase.path;
};
mail.email = "machdas@xyno.space";
mail.email = "plausible@hailsatan.eu";
mail.smtp = {
user = "machdas@xyno.space";
user = "plausible@hailsatan.eu";
passwordFile = config.age.secrets.smtpPassword.path;
hostAddr = "smtp.ionos.de";
hostAddr = "mail.hailsatan.eu";
hostPort = 465;
enableSSL = true;
};