nixos-config/modules/services/goaccess.nix

38 lines
1,019 B
Nix

{pkgs, ...}:
let
imports = ../../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
'';
};
};
};
}