···
cfg = config.services.plausible;
export ADMIN_USER_PWD="$(<${cfg.adminUser.passwordFile})"
export SECRET_KEY_BASE="$(<${cfg.server.secretKeybaseFile})"
-
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";
-
The URL to be used to connect to <package>postgres</package>. The format
-
is described in <link xlink:href="https://hexdocs.pm/ecto/Ecto.Repo.html#module-urls">
-
the elixir docs</link>.
···
-
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.
-
enableSSL = mkEnableOption "";
type = types.ints.unsigned;
···
{ assertion = cfg.adminUser.activate -> cfg.database.postgres.setup;
-
Unable to automatically activate the admin-user if no local DB-managed for
postgres (`services.plausible.database.postgres.setup') is enabled!
···
inherit (pkgs.plausible.meta) description;
documentation = [ "https://plausible.io/docs/self-hosting" ];
-
wantedBy = [ "multi-user.target" ]
-
++ optional cfg.database.clickhouse.setup "clickhouse.service"
-
++ optional cfg.database.postgres.setup "postgresql.service";
after = optional cfg.database.postgres.setup "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;
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;
-
${if cfg.mail.smtp.user != null then "SMTP_USER_NAME" else null} = cfg.mail.smtp.user;
path = [ pkgs.plausible ]
++ optional cfg.database.postgres.setup config.services.postgresql.package;
···
(mkIf cfg.database.postgres.setup {
-
# Unfortunately `plausible' requires super-user permissions in postgresql, so this
-
# has to be done imperatively here.
after = [ "postgresql.service" ];
bindsTo = [ "postgresql.service" ];
requiredBy = [ "plausible.service" ];
partOf = [ "plausible.service" ];
serviceConfig.Type = "oneshot";
-
if [ ! -e /var/lib/plausible/.db-setup ]; then
-
mkdir -p /var/lib/plausible/
-
/run/wrappers/bin/sudo -Hu postgres ${config.services.postgresql.package}/bin/psql --port=5432 "$@"
-
PSQL -tAc "CREATE EXTENSION IF NOT EXISTS citext;"
-
PSQL -tAc "CREATE ROLE plausible WITH LOGIN;"
-
PSQL -tAc "CREATE DATABASE plausible WITH OWNER plausible;"
-
PSQL -tAc "ALTER USER plausible WITH SUPERUSER;"
-
touch /var/lib/plausible/.db-setup