From 4b5dd6a2895dde26c38498d0d899aaa12b009a69 Mon Sep 17 00:00:00 2001 From: "quentin@aristote.fr" Date: Mon, 12 Oct 2026 10:38:20 +0200 Subject: searx: filtron -> limiter --- config/services/web/searx/engines.nix | 111 ++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 config/services/web/searx/engines.nix (limited to 'config/services/web/searx/engines.nix') diff --git a/config/services/web/searx/engines.nix b/config/services/web/searx/engines.nix new file mode 100644 index 0000000..69cc861 --- /dev/null +++ b/config/services/web/searx/engines.nix @@ -0,0 +1,111 @@ +{ lib, ... }: + +with lib; +let + overrideDisabled = + value: names: + map (name: { + inherit name; + disabled = value; + }) names; + enable = overrideDisabled false; + disable = overrideDisabled true; + + makeSearchUrl = + { + baseUrl, + queryKeyword ? "query", + pageKeyword ? null, + preventRedirect ? false, + extraParameters ? { }, + }: + baseUrl + + "?${queryKeyword}={query}" + # an invisible whitespace is added at the end of the query to prevent redirections + + (optionalString preventRedirect "%E2%80%8E") + + (optionalString (pageKeyword != null) "&${pageKeyword}={pageno}") + + (concatStrings ( + mapAttrsToList (name: value: "&${name}=${builtins.toString value}") extraParameters + )); + + wikipediaSearch = lang: { + name = "wikipedia search ${lang}"; + engine = "xpath"; + search_url = makeSearchUrl { + baseUrl = "https://${lang}.wikipedia.org/w/index.php"; + queryKeyword = "search"; + extraParameters = { + fulltext = 1; + }; + }; + results_xpath = ''//ul[@class="mw-search-results"]/li''; + url_xpath = ''.//div[@class="mw-search-result-heading"]/a/@href''; + title_xpath = ''.//div[@class="mw-search-result-heading"]/a/@title''; + content_xpath = ''.//div[@class="searchresult"]''; + shortcut = "w${lang}"; + categories = "general"; + disabled = true; + about = { + website = "https://${lang}.wikipedia.org/"; + wikidata_id = "Q52"; + official_api_documentation = "https://${lang}.wikipedia.org/api/"; + use_official_api = false; + require_api_key = false; + results = "HTML"; + }; + }; +in +{ + services.searx.settings.engines = + (disable [ + # general + "bing" + "brave" + "currency" + "dictzone" + "google" + # files + "btdigg" + # images + "openverse" + "bing images" + "library of congress" + "qwant images" + # it + "hoogle" + # map + "photon" + ]) + ++ (enable [ + # general + "duckduckgo" + "startpage" + ]) + ++ [ + { + name = "nlab"; + engine = "xpath"; + search_url = makeSearchUrl { baseUrl = "https://ncatlab.org/nlab/search"; }; + results_xpath = "//li/a"; + url_xpath = "./@href"; + title_xpath = "."; + content_xpath = "."; + shortcut = "nlab"; + timeout = 10.0; + categories = "science"; + disabled = true; + about = { + website = "https://ncatlab.org/"; + wikidata_id = "Q6954693"; + official_api_documentation = ""; + use_official_api = false; + require_api_key = false; + results = "HTML"; + }; + } + ] + ++ (map wikipediaSearch [ + "fr" + "en" + ]); +} -- cgit v1.3.1