summaryrefslogtreecommitdiff
path: root/config/services/web/searx/engines.nix
diff options
context:
space:
mode:
Diffstat (limited to 'config/services/web/searx/engines.nix')
-rw-r--r--config/services/web/searx/engines.nix111
1 files changed, 111 insertions, 0 deletions
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"
+ ]);
+}