nichts/modules/services/plausible/module.nix

40 lines
878 B
Nix
Raw Normal View History

2025-05-26 10:29:09 +02:00
{
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}";
};
};
};
};
}