all repos — nixfiles @ 3b52b46cd1f54703a236e39cb7ce360365c5913a

System and user configuration, managed by nix and home-manager

extract searchix configuration to role

Alin
commit

3b52b46cd1f54703a236e39cb7ce360365c5913a

parent

0c6feff9df176e2b974d38c6f15169611b7df37b

3 files changed, 122 insertions(+), 106 deletions(-)

changed files
M flake.nix → flake.nix
@@ -140,7 +140,6 @@ modules = [
{ nixpkgs.overlays = [ elgit.overlays.default - searchix.overlays.default ]; } srvos.nixosModules.server
@@ -148,7 +147,6 @@ srvos.nixosModules.hardware-hetzner-cloud-arm
agenix.nixosModules.default elgit.nixosModules.elgit mycal.nixosModules.mycal - searchix.nixosModules.web ./packages/modules/nixos/goaccess.nix ./packages/modules/nixos/laminar.nix ./packages/modules/nixos/git-pr.nix
@@ -163,12 +161,12 @@ modules = [
{ nixpkgs.overlays = [ elgit.overlays.default - searchix.overlays.default ]; } srvos.nixosModules.server vpsadminos.nixosConfigurations.containerUnstable agenix.nixosModules.default + ./packages/modules/nixos/laminar.nix ./system/hosts/smrk.nix ]; };
M system/hosts/linde.nix → system/hosts/linde.nix
@@ -33,6 +33,7 @@
../roles/server.nix ../roles/reverse-proxy.nix ../roles/binary-cache.nix + ../roles/searchix.nix ../settings/services/git-server.nix ]; age.secrets = {
@@ -538,46 +539,6 @@ root * /srv/http/files
file_server browse ''; }; - "searchix.${oldDomain}" = { - extraConfig = '' - redir https://searchix.ovh{uri} permanent - ''; - }; - "searchix.ovh" = { - extraConfig = '' - root ${pkgs.searchix}/lib/searchix - handle_errors { - rewrite * /error.html - templates - file_server - } - handle_path /stats/* { - root /srv/http/access/searchix - file_server - } - handle { - log_skip /health - reverse_proxy localhost:${toString config.services.searchix.settings.web.port} { - health_uri /health - health_status 2xx - health_interval 10s - health_timeout 1s - health_fails 2 - } - } - 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* - } - } - ''; - }; "ci.${domain}" = let srv = config.services.laminar;
@@ -698,26 +659,6 @@ OPENAI_API_BASE_URL = "https://openrouter.ai/api/vi";
}; }; - services.goaccess = { - group = "caddy"; - instances = { - searchix = { - enable = true; - dates = "hourly"; - settings = { - log-file = "${config.services.caddy.logDir}/access-searchix.ovh.log"; - output = "/srv/http/access/searchix/index.html"; - log-format = "caddy"; - anonymize-ip = true; - anonymize-level = 2; - persist = true; - restore = true; - keep-last = 90; # days - }; - }; - }; - }; - networking.nat = { enable = true; internalInterfaces = [ "ve-+" ];
@@ -877,49 +818,6 @@ guiAddress = "[::]:8384";
openDefaultPorts = true; overrideDevices = false; overrideFolders = false; - }; - - services.searchix = { - enable = true; - environment = { - GOMEMLIMIT = "2000MiB"; - }; - settings = { - web = { - baseURL = "https://searchix.ovh"; - searchTimeout = "2s"; - }; - - importer.timeout = "2h"; - importer.sources = { - darwin = { - enable = true; - fetcher = "download"; - url = "https://alinnow.github.io/nix-options/darwin"; - }; - home-manager = { - enable = true; - fetcher = "download"; - url = "https://alinnow.github.io/nix-options/home-manager"; - }; - nixpkgs = { - enable = true; - fetcher = "channel-nixpkgs"; - channel = "nixos-unstable"; - timeout = "1h"; - }; - nixos = { - enable = true; - fetcher = "channel-nixpkgs"; - channel = "nixos-unstable"; - }; - nur.enable = true; - }; - }; - }; - systemd.services.searchix.serviceConfig = { - MemoryHigh = "1.5G"; - MemoryMax = "2G"; }; programs.git = {
A system/roles/searchix.nix
@@ -0,0 +1,120 @@
+{ + config, + inputs, + pkgs, + ... +}: +{ + imports = [ + inputs.searchix.nixosModules.web + ]; + nixpkgs.overlays = [ + inputs.searchix.overlays.default + ]; + + services.searchix = { + enable = true; + environment = { + GOMEMLIMIT = "1500MiB"; + }; + settings = { + web = { + baseURL = "https://searchix.ovh"; + searchTimeout = "2s"; + }; + + importer.timeout = "2h"; + importer.sources = { + darwin = { + enable = true; + fetcher = "download"; + url = "https://alinnow.github.io/nix-options/darwin"; + }; + home-manager = { + enable = true; + fetcher = "download"; + url = "https://alinnow.github.io/nix-options/home-manager"; + }; + nixpkgs = { + enable = true; + fetcher = "channel-nixpkgs"; + channel = "nixos-unstable"; + timeout = "1h"; + }; + nixos = { + enable = true; + fetcher = "channel-nixpkgs"; + channel = "nixos-unstable"; + }; + nur.enable = true; + }; + }; + }; + + systemd.services.searchix.serviceConfig = { + MemoryHigh = "1.2G"; + MemoryMax = "1.5G"; + }; + services.caddy.virtualHosts = { + "searchix.ovh" = { + extraConfig = '' + root ${pkgs.searchix}/lib/searchix + handle_errors { + rewrite * /error.html + templates + file_server + } + handle_path /stats/* { + root /srv/http/access/searchix + file_server + } + handle { + reverse_proxy localhost:${toString config.services.searchix.settings.web.port} { + health_uri /health + health_status 2xx + health_interval 10s + health_timeout 1s + health_fails 2 + } + } + 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* + } + } + ''; + }; + "searchix.alanpearce.eu" = { + extraConfig = '' + redir https://searchix.ovh{uri} permanent + ''; + }; + }; + + services.goaccess = { + group = "caddy"; + instances = { + searchix = { + enable = true; + dates = "hourly"; + settings = { + log-file = "${config.services.caddy.logDir}/access-searchix.ovh.log"; + output = "/srv/http/access/searchix/index.html"; + log-format = "caddy"; + anonymize-ip = true; + anonymize-level = 2; + persist = true; + restore = true; + keep-last = 90; # days + }; + }; + }; + }; + +}