services: plausible: init

This commit is contained in:
Bloxx12 2025-05-26 10:29:09 +02:00
commit 9deefd02e5
Signed by: faukah
SSH key fingerprint: SHA256:Uj2AXqvtdCA4hn5Hq0ZonhIAyUqI1q4w2sMG3Z1TH7E
2 changed files with 44 additions and 0 deletions

View file

@ -0,0 +1,39 @@
{
config,
lib,
pkgs,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.options) mkEnableOption;
cfg = config.modules.system.services.plausible;
port = 4030;
domain = "analytics.copeberg.org";
in {
options.modules.system.services.plausible.enable = mkEnableOption "Plausible, an analytics service";
config = mkIf cfg.enable {
services.plausible = {
enable = true;
server = {
baseUrl = domain;
secretKeybaseFile = "/run/secrets/plausible-secret-key-base";
disableRegistration = false;
};
database.postgres = {
dbname = "plausible";
};
};
services.nginx = {
enable = true;
virtualHosts.${domain} = {
addSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
};
};
}

View file

@ -29,6 +29,7 @@ in {
"git" "git"
"grafana" "grafana"
"stalwart" "stalwart"
"plausible"
]; ];
ensureUsers = [ ensureUsers = [
@ -54,6 +55,10 @@ in {
name = "stalwart"; name = "stalwart";
ensureDBOwnership = true; ensureDBOwnership = true;
} }
{
name = "plausible";
ensureDBOwnership = true;
}
]; ];
settings = { settings = {
# taken from https://pgconfigurator.cybertec.at/ # taken from https://pgconfigurator.cybertec.at/