···
with open("${cfg.djangoSecretKeyFile}") as f:
SECRET_KEY = f.read().rstrip("\n")
···
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "unix://${config.services.redis.servers.weblate.unixSocket}",
+
"CLIENT_CLASS": "django_redis.client.DefaultClient",
+
"CONNECTION_POOL_KWARGS": {},
···
CELERY_TASK_ALWAYS_EAGER = False
CELERY_BROKER_URL = "redis+socket://${config.services.redis.servers.weblate.unixSocket}"
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
···
OTP_WEBAUTHN_RP_NAME = SITE_TITLE
OTP_WEBAUTHN_RP_ID = SITE_DOMAIN.split(":")[0]
OTP_WEBAUTHN_ALLOWED_ORIGINS = [SITE_URL]
+
+ lib.optionalString cfg.configurePostgresql ''
+
"ENGINE": "django.db.backends.postgresql",
+
"HOST": "/run/postgresql",
+ lib.optionalString cfg.smtp.enable ''
EMAIL_HOST = "${cfg.smtp.host}"
+
EMAIL_PORT = ${builtins.toString cfg.smtp.port}
+
SERVER_EMAIL = "${cfg.smtp.from}"
+
DEFAULT_FROM_EMAIL = "${cfg.smtp.from}"
+
+ lib.optionalString (cfg.smtp.enable && cfg.smtp.user != null) ''
+
ADMINS = (("Weblate Admin", "${cfg.smtp.user}"),)
EMAIL_HOST_USER = "${cfg.smtp.user}"
+
+ lib.optionalString (cfg.smtp.enable && cfg.smtp.passwordFile != null) ''
with open("${cfg.smtp.passwordFile}") as f:
EMAIL_HOST_PASSWORD = f.read().rstrip("\n")
···
···
+
configurePostgresql = lib.mkOption {
+
Whether to enable and configure a local PostgreSQL server by creating a user and database for weblate.
+
The default `settings` reference this database, if you disable this option you must provide a database URL in `extraConfig`.
extraConfig = lib.mkOption {
···
enable = lib.mkEnableOption "Weblate SMTP support";
+
description = "The from address being used in sent emails.";
+
example = "weblate@example.com";
+
default = config.services.weblate.smtp.user;
+
defaultText = "config.services.weblate.smtp.user";
description = "SMTP login name.";
example = "weblate@example.org";
+
type = lib.types.nullOr lib.types.str;
···
+
description = "SMTP port used when sending emails to users.";
passwordFile = lib.mkOption {
Location of a file containing the SMTP password.
This should be a path pointing to a file with secure permissions (not /nix/store).
+
type = lib.types.nullOr lib.types.path;
···
"/media/".alias = "/var/lib/weblate/media/";
"/".proxyPass = "http://unix:///run/weblate.socket";
···
systemd.services.weblate-migrate = {
description = "Weblate migration";
+
"weblate-postgresql-setup.service"
+
"redis-weblate.service"
+
"weblate-postgresql-setup.service"
+
"redis-weblate.service"
# We want this to be active on boot, not just on socket activation
wantedBy = [ "multi-user.target" ];
···
description = "Weblate Celery";
+
"redis-weblate.service"
# We want this to be active on boot, not just on socket activation
···
+
services.postgresql = lib.mkIf cfg.configurePostgresql {