nixos-config/modules/services/goaccess.nix
2025-10-09 17:40:43 +02:00

38 lines
1 KiB
Nix

{pkgs, ...}:
let
globals = import ../../config/globals.nix ;
in {
environment.systemPackages = with pkgs; [
goaccess
];
# Service pour générer le rapport statique GoAccess
systemd.services.goaccess-report = {
description = "Generate GoAccess HTML report";
serviceConfig = {
ExecStart = "${pkgs.goaccess}/bin/goaccess /var/log/caddy/access-${globals.services.levr.url}.log --log-format=CADDY -o ${globals.services.goaccess.home}/index.html";
};
};
# Timer pour régénérer le rapport toutes les heures
systemd.timers.goaccess-report = {
description = "Hourly GoAccess report generation";
wantedBy = ["timers.target"];
timerConfig = {
OnCalendar = "hourly";
Persistent = true;
};
};
services.caddy = {
virtualHosts = {
"${globals.services.goaccess.url}" = {
extraConfig = ''
root * ${globals.services.goaccess.home}
file_server browse
try_files {path} {path}/ /index.html
'';
};
};
};
}