system/roles/searchix-stable-container.nix (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | {
config,
inputs,
pkgs,
...
}:
let
stableVersion = "26.05";
in
{
imports = [
../../packages/modules/nixos/goaccess.nix
];
containers.searchix-stable = {
autoStart = true;
config = {
imports = [
inputs.searchix.nixosModules.web
];
system.stateVersion = stableVersion;
services.searchix = {
enable = true;
environment = {
GOMEMLIMIT = "1000MiB";
};
settings = {
web = {
baseURL = "https://stable.searchix.ovh";
port = 51314;
searchTimeout = "2s";
gracefulShutdownTimeout = "2s";
};
importer = {
timeout = "45m";
updateAt = "07:00:00";
batchSize = 2000;
sources = {
nixpkgs = {
enable = true;
fetcher = "channel-nixpkgs";
channel = "nixos-${stableVersion}";
timeout = "30m";
manpages = {
enable = true;
path = "/doc/manpage-urls.json";
};
};
nixos = {
enable = true;
fetcher = "channel-nixpkgs";
channel = "nixos-${stableVersion}";
};
darwin = {
enable = true;
fetcher = "download";
url = "https://alinnow.github.io/nix-options/nix-darwin-stable";
};
home-manager = {
enable = true;
fetcher = "download";
url = "https://alinnow.github.io/nix-options/home-manager-stable";
};
};
};
};
};
};
};
systemd.services."container@searchix-stable".stopIfChanged = false;
services.caddy.virtualHosts = {
"stable.searchix.ovh" = {
extraConfig = ''
root ${pkgs.searchix}/lib/searchix
handle_errors {
rewrite * /error.html
templates
file_server
}
handle_path /stats/* {
root /srv/http/access/searchix-stable
file_server
log_skip
reverse_proxy /ws {
to unix/${config.services.goaccess.instances.stable-searchix.settings.unix-socket}
}
}
handle {
reverse_proxy localhost:51314 {
health_uri /health
health_status 2xx
}
}
encode zstd gzip {
match {
header Content-Type text/*
header Content-Type application/json*
header Content-Type application/javascript*
header Content-Type application/opensearchdescription+xml
header Content-Type application/atom+xml*
header Content-Type application/rss+xml*
header Content-Type image/svg+xml*
}
}
'';
};
};
services.goaccess.instances = {
stable-searchix = {
enable = true;
settings = {
real-time-html = true;
ws-url = "wss://stable.searchix.ovh:443/stats/ws";
addr = null;
port = null;
unix-socket = "/var/run/goaccess/stable-searchix/sock";
log-file = "${config.services.caddy.logDir}/access-stable.searchix.ovh.log";
output = "/srv/http/access/searchix-stable/index.html";
log-format = "caddy";
anonymize-ip = true;
anonymize-level = 2;
persist = true;
restore = true;
keep-last = 90; # days
};
};
};
}
|