···
cfg = config.services.plausible;
8
+
# FIXME consider using LoadCredential as soon as it actually works.
export ADMIN_USER_PWD="$(<${cfg.adminUser.passwordFile})"
export SECRET_KEY_BASE="$(<${cfg.server.secretKeybaseFile})"
11
-
export RELEASE_TMP=/var/lib/plausible/tmp
${optionalString (cfg.mail.smtp.passwordFile != null) ''
export SMTP_USER_PWD="$(<${cfg.mail.smtp.passwordFile})"
···
default = "http://localhost:8123/default";
54
-
The URL to be used to connect to <package>postgres</package>. The format
55
-
is described in <link xlink:href="https://hexdocs.pm/ecto/Ecto.Repo.html#module-urls">
56
-
the elixir docs</link>.
54
+
The URL to be used to connect to <package>clickhouse</package>.
···
113
-
default = " hello@plausible.local";
111
+
default = "hello@plausible.local";
The email id to use for as <emphasis>from</emphasis> address of all communications
···
The path to the file with the password in case SMTP auth is enabled.
149
-
enableSSL = mkEnableOption "";
147
+
enableSSL = mkEnableOption "SSL when connecting to the SMTP server";
type = types.ints.unsigned;
···
{ assertion = cfg.adminUser.activate -> cfg.database.postgres.setup;
165
-
Unable to automatically activate the admin-user if no local DB-managed for
163
+
Unable to automatically activate the admin-user if no locally DB-managed for
postgres (`services.plausible.database.postgres.setup') is enabled!
···
inherit (pkgs.plausible.meta) description;
documentation = [ "https://plausible.io/docs/self-hosting" ];
184
-
wantedBy = [ "multi-user.target" ]
185
-
++ optional cfg.database.clickhouse.setup "clickhouse.service"
186
-
++ optional cfg.database.postgres.setup "postgresql.service";
182
+
wantedBy = [ "multi-user.target" ];
after = optional cfg.database.postgres.setup "plausible-postgres.service";
184
+
requires = optional cfg.database.clickhouse.setup "clickhouse.service"
185
+
++ optionals cfg.database.postgres.setup [
186
+
"postgresql.service"
187
+
"plausible-postgres.service"
# NixOS specific option to avoid that it's trying to write into its store-path.
···
PORT = toString cfg.server.port;
DISABLE_REGISTRATION = boolToString cfg.server.disableRegistration;
200
+
RELEASE_TMP = "/var/lib/plausible/tmp";
ADMIN_USER_NAME = cfg.adminUser.name;
ADMIN_USER_EMAIL = cfg.adminUser.email;
···
SMTP_HOST_PORT = toString cfg.mail.smtp.hostPort;
SMTP_RETRIES = toString cfg.mail.smtp.retries;
SMTP_HOST_SSL_ENABLED = boolToString cfg.mail.smtp.enableSSL;
213
-
${if cfg.mail.smtp.user != null then "SMTP_USER_NAME" else null} = cfg.mail.smtp.user;
218
+
} // (optionalAttrs (cfg.mail.smtp.user != null) {
219
+
SMTP_USER_NAME = cfg.mail.smtp.user;
path = [ pkgs.plausible ]
++ optional cfg.database.postgres.setup config.services.postgresql.package;
···
(mkIf cfg.database.postgres.setup {
242
-
# Unfortunately `plausible' requires super-user permissions in postgresql, so this
243
-
# has to be done imperatively here.
248
+
# `plausible' requires the `citext'-extension.
after = [ "postgresql.service" ];
bindsTo = [ "postgresql.service" ];
requiredBy = [ "plausible.service" ];
partOf = [ "plausible.service" ];
serviceConfig.Type = "oneshot";
255
+
unitConfig.ConditionPathExists = "!/var/lib/plausible/.db-setup";
251
-
if [ ! -e /var/lib/plausible/.db-setup ]; then
252
-
mkdir -p /var/lib/plausible/
254
-
/run/wrappers/bin/sudo -Hu postgres ${config.services.postgresql.package}/bin/psql --port=5432 "$@"
256
-
PSQL -tAc "CREATE EXTENSION IF NOT EXISTS citext;"
257
-
PSQL -tAc "CREATE ROLE plausible WITH LOGIN;"
258
-
PSQL -tAc "CREATE DATABASE plausible WITH OWNER plausible;"
259
-
PSQL -tAc "ALTER USER plausible WITH SUPERUSER;"
260
-
touch /var/lib/plausible/.db-setup
257
+
mkdir -p /var/lib/plausible/
259
+
/run/wrappers/bin/sudo -Hu postgres ${config.services.postgresql.package}/bin/psql --port=5432 "$@"
261
+
PSQL -tAc "CREATE ROLE plausible WITH LOGIN;"
262
+
PSQL -tAc "CREATE DATABASE plausible WITH OWNER plausible;"
263
+
PSQL -d plausible -tAc "CREATE EXTENSION IF NOT EXISTS citext;"
264
+
touch /var/lib/plausible/.db-setup