summaryrefslogtreecommitdiff
path: root/modules/nixos/searx.nix
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2022-12-17 16:39:09 +0300
committerAzat Bahawi <azat@bahawi.net>2022-12-17 16:39:09 +0300
commit8f137c28230623259a964484adcf31fe00756594 (patch)
tree82bce6a13fda125087cf6d9dc80aa91d9230d6c4 /modules/nixos/searx.nix
parent3229e56e0d3620ddc735edcfbbefb167efa3b23f (diff)
2022-12-17
Diffstat (limited to 'modules/nixos/searx.nix')
-rw-r--r--modules/nixos/searx.nix78
1 files changed, 78 insertions, 0 deletions
diff --git a/modules/nixos/searx.nix b/modules/nixos/searx.nix
new file mode 100644
index 0000000..9462d5d
--- /dev/null
+++ b/modules/nixos/searx.nix
@@ -0,0 +1,78 @@
+{
+ config,
+ inputs,
+ lib,
+ ...
+}:
+with lib; let
+ cfg = config.nixfiles.modules.searx;
+in {
+ options.nixfiles.modules.searx = {
+ enable = mkEnableOption "SearX";
+
+ port = mkOption {
+ description = "Port.";
+ type = with types; port;
+ default = 61001;
+ };
+
+ domain = mkOption {
+ description = "Domain name sans protocol scheme.";
+ type = with types; nullOr str;
+ default = "searx.${config.networking.domain}";
+ };
+ };
+
+ config = mkIf cfg.enable {
+ secrets.searx-environment = {
+ file = "${inputs.self}/secrets/searx-environment";
+ owner = "searx";
+ group = "searx";
+ };
+
+ nixfiles.modules.nginx = {
+ enable = true;
+ upstreams.searx.servers."127.0.0.1:${toString cfg.port}" = {};
+ virtualHosts.${cfg.domain} = {
+ locations."/".proxyPass = "http://searx";
+ extraConfig = nginxInternalOnly;
+ };
+ };
+
+ services = {
+ searx = {
+ enable = true;
+
+ settings = {
+ general = {
+ instance_name = cfg.domain;
+ contact_url = "mailto:admin+searx@${config.networking.domain}";
+ git_url = false;
+ git_branch = false;
+ docs_url = false;
+ wiki_url = false;
+ twitter_url = false;
+ };
+ server = {
+ bind_address = "127.0.0.1";
+ inherit (cfg) port;
+ secret_key = "@SEARX_SECRET_KEY@";
+ base_url = false;
+ image_proxy = false;
+ default_http_headers = {
+ Referrer-Policy = "no-referrer";
+ X-Content-Type-Options = "nosniff";
+ X-Download-Options = "noopen";
+ X-Robots-Tag = "noindex, nofollow, nosnippet, noarchive";
+ };
+ };
+ search = {
+ safe_search = 0;
+ autocomplete = "";
+ };
+ };
+ environmentFile = config.secrets.searx-environment.path;
+ };
+ };
+ };
+}