summaryrefslogtreecommitdiff
path: root/config/services/web
diff options
context:
space:
mode:
Diffstat (limited to 'config/services/web')
-rw-r--r--config/services/web/searx/searx/default.nix4
-rw-r--r--config/services/web/searx/searx/engines.nix189
2 files changed, 109 insertions, 84 deletions
diff --git a/config/services/web/searx/searx/default.nix b/config/services/web/searx/searx/default.nix
index 72155c2..cf50343 100644
--- a/config/services/web/searx/searx/default.nix
+++ b/config/services/web/searx/searx/default.nix
@@ -6,6 +6,9 @@ let
filtron = config.services.filtron;
};
in {
+
+ imports = [ ./engines.nix ];
+
services.searx = {
enable = true;
@@ -47,7 +50,6 @@ in {
"Tracker URL remover"
"Vim-like hotkeys"
];
- engines = import ./engines.nix;
};
};
}
diff --git a/config/services/web/searx/searx/engines.nix b/config/services/web/searx/searx/engines.nix
index 70a4cb2..3eefc5d 100644
--- a/config/services/web/searx/searx/engines.nix
+++ b/config/services/web/searx/searx/engines.nix
@@ -1,3 +1,6 @@
+{ lib, ... }:
+
+with lib;
let
overrideDisabled = value: names:
map (name: {
@@ -6,87 +9,107 @@ let
}) names;
enable = overrideDisabled false;
disable = overrideDisabled true;
-in (disable [
- # general
- "bing"
- "currency"
- "dictzone"
- # files
- "btdigg"
- "torrentz"
- # images
- "bing images"
- "ccengine"
- "library of congress"
- "qwant images"
- # it
- "hoogle"
- # map
- "photon"
-]) ++ (enable [
- # General
- "duckduckgo"
-]) ++ [
- { # AlternativeTo
- name = "alternativeto";
- engine = "xpath";
- paging = true;
+
+ makeSearchUrl = { baseUrl, queryKeyword ? "query", pageKeyword ? null
+ , preventRedirect ? false }:
+ baseUrl + "?${queryKeyword}={query}"
# an invisible whitespace is added at the end of the query to prevent redirections
- search_url = "https://alternativeto.net/browse/search?q={query}%E2%80%8E&p={pageno}";
- results_xpath = ''
- //article[@class="row app-list-item"]/div[@class="col-xs-10 col-sm-10 col-md-11 col-lg-offset-1 col-lg-11"]'';
- url_xpath = "./h3/a/@href";
- title_xpath = "./h3/a";
- content_xpath = ''./div[@class="itemDesc read-more-box"]/p[@class="text"]'';
- shortcut = "a2";
- categories = "it";
- disabled = true;
- about = {
- website = "https://alternativeto.net/";
- wikidata_id = "Q3613175";
- official_api_documentation = "";
- use_official_api = false;
- require_api_key = false;
- results = "HTML";
- };
- }
- { # Emojipedia
- name = "emojipedia";
- engine = "xpath";
- # an invisible whitespace is added at the end of the query to prevent redirections
- search_url = "https://emojipedia.org/search/?q={query}%E2%80%8E";
- url_xpath = ''//ol[@class="search-results"]/li/h2/a/@href'';
- title_xpath = ''//ol[@class="search-results"]/li/h2/a'';
- content_xpath = ''//ol[@class="search-results"]/li/p'';
- shortcut = "emoji";
- disabled = true;
- about = {
- website = "https://emojipedia.org/";
- wikidata_id = "Q22908129";
- official_api_documentation = "";
- use_official_api = false;
- require_api_key = false;
- results = "HTML";
- };
- }
- {
- name = "nlab";
- engine = "xpath";
- search_url = "https://ncatlab.org/nlab/search?query={query}";
- url_xpath = "//li/a/@href";
- title_xpath = "//li/a";
- content_xpath = "//li/a";
- 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";
- };
- }
-]
+ + (optionalString preventRedirect "%E2%80%8E")
+ + (optionalString (pageKeyword != null) "&${page_keyword}={page_no}");
+in {
+ services.searx.settings.engine = (disable [
+ # general
+ "bing"
+ "currency"
+ "dictzone"
+ # files
+ "btdigg"
+ "torrentz"
+ # images
+ "bing images"
+ "ccengine"
+ "library of congress"
+ "qwant images"
+ # it
+ "hoogle"
+ # map
+ "photon"
+ ]) ++ (enable [
+ # general
+ "duckduckgo"
+ ]) ++ [
+ { # AlternativeTo
+ name = "alternativeto";
+ engine = "xpath";
+ paging = true;
+ search_url = makeSearchUrl {
+ baseUrl = "https://alternativeto.net/browse/search";
+ queryKeyword = "q";
+ pageKeyword = "p";
+ preventRedirect = true;
+ };
+ results_xpath = ''
+ //article[@class="row app-list-item"]/div[@class="col-xs-10 col-sm-10 col-md-11 col-lg-offset-1 col-lg-11"]'';
+ url_xpath = "./h3/a/@href";
+ title_xpath = "./h3/a";
+ content_xpath =
+ ''./div[@class="itemDesc read-more-box"]/p[@class="text"]'';
+ shortcut = "a2";
+ categories = "it";
+ disabled = true;
+ about = {
+ website = "https://alternativeto.net/";
+ wikidata_id = "Q3613175";
+ official_api_documentation = "";
+ use_official_api = false;
+ require_api_key = false;
+ results = "HTML";
+ };
+ }
+ { # Emojipedia
+ name = "emojipedia";
+ engine = "xpath";
+ search_url = makeSearchUrl {
+ baseUrl = "https://emojipedia.org/search/";
+ queryKeyword = "q";
+ preventRedirect = true;
+ };
+ results_xpath = ''//ol[@class="search-results"]/li'';
+ url_xpath = "./h2/a/@href";
+ title_xpath = "./h2/a";
+ content_xpath = "./p";
+ shortcut = "emoji";
+ disabled = true;
+ about = {
+ website = "https://emojipedia.org/";
+ wikidata_id = "Q22908129";
+ official_api_documentation = "";
+ use_official_api = false;
+ require_api_key = false;
+ results = "HTML";
+ };
+ }
+ {
+ 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";
+ };
+ }
+ ];
+}