Files
nixos/services/searxng.nix

84 lines
2.0 KiB
Nix

# Module: services/searxng
# Enables a searxng server
{
config,
lib,
pkgs,
pkgsUnstable,
inputs,
...
}:
with lib;
let
cfg = config.searxng;
searxngPort = 8888;
in
{
options.searxng = {
enable = mkEnableOption "Enables searxng module";
environmentFile = mkOption {
type = types.path;
default = null;
description = "Path of encrypted environment file containing secrets for the searxng config";
example = "../secrets/searxng.env";
};
};
config = mkIf cfg.enable {
services.searx = {
enable = true;
package = pkgsUnstable.searxng;
redisCreateLocally = true;
environmentFile = cfg.environmentFile;
settings = {
general = {
debug = false;
privacypolicyurl = false;
instance_name = "ET's Search";
donation_url = false;
contact_url = false;
# TODO set up sops here
#enable_metrics = true;
#open_metrics = ""
};
search = {
safe_search = 0;
};
server = {
port = searxngPort;
bind_address = "127.0.0.1";
base_url = "https://${config.networking.hostName}.tail755c5.ts.net/search/";
public_instance = false;
method = "POST";
secret_key = "@SEARXNG_SECRET@";
};
ui = {
infinite_scroll = true;
default_theme = "simple";
results_on_new_tab = true;
hotkeys = "vim";
url_formatting = "pretty";
};
};
};
services.traefik.dynamicConfigOptions = {
http.routers.searxng = {
entrypoints = [ "websecure" ];
rule = "Host(`${config.networking.hostName}.tail755c5.ts.net`) && PathPrefix(`/search`)";
tls.certresolver = "tailscale";
service = "searxng";
};
http.services.searxng.loadbalancer.servers = [
{
url = "http://127.0.0.1:${toString searxngPort}";
}
];
};
};
}