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; };
};
});
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
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" ''