{ config, lib, pkgs, options, ... }: with lib; let cfg = config.modules.services.matomo; in { options.modules.services.matomo = { enable = mkOption { type = types.bool; default = false; }; domain = mkOption { type = types.str; default = "analytics.reidlab.pink"; }; }; config = mkIf cfg.enable { services.matomo = { enable = true; package = pkgs.matomo; periodicArchiveProcessing = true; hostname = cfg.domain; nginx = { serverAliases = [ cfg.domain ]; enableACME = true; }; }; # matomo doesn't automatically create the database # just. make sure its named matomo services.mysql = { ensureDatabases = [ "matomo" ]; ensureUsers = [ { name = "matomo"; ensurePermissions = { "matomo.*" = "ALL PRIVILEGES"; }; } ]; }; }; }