X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=nixops%2Fmodules%2Fwebsites%2Fcommons%2Fstats.nix;h=73595f1ff7e71838c5e0068ac68939cba239e04a;hb=b7ee93fcdee2509cd4c0caec2c5c59ccff5bab2c;hp=88559b1e573d1262c9b26a36c169f68ebd5df3a0;hpb=f826c67c0ff51c9724e8f54da6c9cbef78977858;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/nixops/modules/websites/commons/stats.nix b/nixops/modules/websites/commons/stats.nix index 88559b1..73595f1 100644 --- a/nixops/modules/websites/commons/stats.nix +++ b/nixops/modules/websites/commons/stats.nix @@ -8,7 +8,10 @@ in { sites = lib.mkOption { type = lib.types.listOf (lib.types.submodule { options = { - conf = lib.mkOption { type = lib.types.path; }; + conf = lib.mkOption { + type = lib.types.nullOr lib.types.path; + default = null; + }; name = lib.mkOption { type = lib.types.string; }; }; }); @@ -27,6 +30,11 @@ in { enable = true; systemCronJobs = let stats = domain: conf: let + config = if builtins.isNull conf + then pkgs.runCommand "goaccess.conf" { + dbPath = "/var/lib/goaccess/${domain}"; + } "substituteAll ${./goaccess.conf} $out" + else conf; d = pkgs.writeScriptBin "stats-${domain}" '' #!${pkgs.stdenv.shell} set -e @@ -39,7 +47,7 @@ in { for i in /var/log/httpd/access_log-${domain}*.gz; do zcat "$i" | sed -n "/\\[$date_regex/ p" >> $TMPFILE done - ${pkgs.goaccess}/bin/goaccess $TMPFILE --no-progress -o /var/lib/goaccess/${domain}/index.html -p ${conf} + ${pkgs.goaccess}/bin/goaccess $TMPFILE --no-progress -o /var/lib/goaccess/${domain}/index.html -p ${config} ''; in "${d}/bin/stats-${domain}"; allStats = sites: pkgs.writeScript "stats" ''