···
53
-
"ENGINE": "django.db.backends.postgresql",
54
-
"HOST": "/run/postgresql",
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}",
68
-
"CLIENT_CLASS": "django_redis.client.DefaultClient",
70
-
"CONNECTION_POOL_KWARGS": {},
59
+
"CLIENT_CLASS": "django_redis.client.DefaultClient",
61
+
"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]
87
+
+ lib.optionalString cfg.configurePostgresql ''
90
+
"ENGINE": "django.db.backends.postgresql",
91
+
"HOST": "/run/postgresql",
+ lib.optionalString cfg.smtp.enable ''
99
-
ADMINS = (("Weblate Admin", "${cfg.smtp.user}"),)
EMAIL_HOST = "${cfg.smtp.host}"
100
+
EMAIL_PORT = ${builtins.toString cfg.smtp.port}
101
+
SERVER_EMAIL = "${cfg.smtp.from}"
102
+
DEFAULT_FROM_EMAIL = "${cfg.smtp.from}"
104
+
+ lib.optionalString (cfg.smtp.enable && cfg.smtp.user != null) ''
105
+
ADMINS = (("Weblate Admin", "${cfg.smtp.user}"),)
EMAIL_HOST_USER = "${cfg.smtp.user}"
104
-
SERVER_EMAIL = "${cfg.smtp.user}"
105
-
DEFAULT_FROM_EMAIL = "${cfg.smtp.user}"
108
+
+ lib.optionalString (cfg.smtp.enable && cfg.smtp.passwordFile != null) ''
with open("${cfg.smtp.passwordFile}") as f:
EMAIL_HOST_PASSWORD = f.read().rstrip("\n")
···
···
171
+
configurePostgresql = lib.mkOption {
172
+
type = lib.types.bool;
175
+
Whether to enable and configure a local PostgreSQL server by creating a user and database for weblate.
176
+
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";
191
+
from = lib.mkOption {
192
+
description = "The from address being used in sent emails.";
193
+
example = "weblate@example.com";
194
+
default = config.services.weblate.smtp.user;
195
+
defaultText = "config.services.weblate.smtp.user";
196
+
type = lib.types.str;
description = "SMTP login name.";
example = "weblate@example.org";
182
-
type = lib.types.str;
202
+
type = lib.types.nullOr lib.types.str;
···
212
+
port = lib.mkOption {
213
+
description = "SMTP port used when sending emails to users.";
214
+
type = lib.types.port;
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).
197
-
type = lib.types.path;
225
+
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";
240
-
after = [ "weblate-postgresql-setup.service" ];
241
-
requires = [ "weblate-postgresql-setup.service" ];
268
+
"weblate-postgresql-setup.service"
269
+
"redis-weblate.service"
272
+
"weblate-postgresql-setup.service"
273
+
"redis-weblate.service"
# We want this to be active on boot, not just on socket activation
wantedBy = [ "multi-user.target" ];
···
description = "Weblate Celery";
292
+
"redis-weblate.service"
# We want this to be active on boot, not just on socket activation
···
374
-
services.postgresql = {
407
+
services.postgresql = lib.mkIf cfg.configurePostgresql {