Add plausible

This commit is contained in:
Ivan R. 2023-08-19 20:27:34 +05:00
parent 0af7d3e6a4
commit 445ad3c38e
No known key found for this signature in database
GPG key ID: 56C7BAAE859B302C
4 changed files with 68 additions and 0 deletions

View file

@ -18,6 +18,8 @@
./programs/synapse.nix
./programs/fail2ban.nix
./programs/maddy.nix
./programs/plausible.nix
./programs/clickhouse.nix
];
# Enable flakes

View file

@ -0,0 +1,6 @@
{ config, ... }:
{
services.clickhouse = {
enable = true;
};
}

View file

@ -58,6 +58,17 @@ in {
};
};
# Plausible
"plausible.comfycamp.space" = {
useACMEHost = "comfycamp.space";
forceSSL = true;
locations = {
"/" = {
proxyPass = "http://127.0.0.1:55005";
};
};
};
# Mail: MTA-STS
"mta-sts.comfycamp.space" = {
useACMEHost = "comfycamp.space";

View file

@ -0,0 +1,49 @@
{ config, lib, ... }:
{
services.plausible = {
enable = true;
releaseCookiePath = "/var/lib/secrets/plausible/release-cookie.txt";
database.postgres = {
setup = false;
dbname = "plausible";
};
database.clickhouse = {
setup = false;
url = "http://localhost:8123/plausible";
};
server = {
baseUrl = "https://plausible.comfycamp.space";
port = 55005;
secretKeybaseFile = "/var/lib/secrets/plausible/keybase.txt";
};
adminUser = {
name = "lumin";
email = "lumin@comfycamp.space";
passwordFile = "/var/lib/secrets/plausible/admin-pass.txt";
};
mail = {
email = "plausible@comfycamp.space";
smtp = {
enableSSL = true;
hostAddr = "comfycamp.space";
hostPort = 465;
passwordFile = "/var/lib/secrets/plausible/smtp-pass.txt";
user = "plausible@comfycamp.space";
};
};
};
systemd.services.plausible.script = lib.mkForce ''
export CONFIG_DIR=$CREDENTIALS_DIRECTORY
export RELEASE_COOKIE="$(< $CREDENTIALS_DIRECTORY/RELEASE_COOKIE )"
# Do not create the database.
# https://github.com/plausible/analytics/issues/405
# ${config.services.plausible.package}/createdb.sh
${config.services.plausible.package}/migrate.sh
exec plausible start
'';
}