summaryrefslogtreecommitdiff
path: root/config/services/web/searx/default.nix
blob: 668136695741442cad50ff63bca352bee9143837 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{
  config,
  lib,
  pkgs,
  ...
}:

let
  cfg = config.services.searx;
in
{
  imports = [
    ./engines.nix
    ./limiter.nix
  ];

  services.nginx.virtualHosts."searx.aristote.fr" = lib.mkIf (cfg.enable && cfg.configureNginx) {
    locations."/" = {
      extraConfig = ''
        proxy_set_header Host            $host;
        proxy_set_header Connection      $http_connection;
        proxy_set_header X-Real-IP       $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Scheme        $scheme;
        # proxy_set_header X-Script-Name   /;
      '';
    };
    forceSSL = true;
    enableACME = true;
  };

  services.searx = {
    enable = true;
    package = pkgs.searxng;

    configureNginx = true;
    domain = "searx.aristote.fr";

    configureUwsgi = true;
    uwsgiConfig = {
      cache2 = "name=searxcache,items=2000,blocks=2000,blocksize=4096,bitmap=1";
    };

    environmentFile = "/etc/searx/secrets";
    settings = {
      use_default_settings = true;
      general = {
        debug = true;
        contact_url = "mailto:quentin@${config.networking.domain}";
        enable_stats = false;
      };
      search = {
        autocomplete = "wikipedia";
        default_lang = "all";
        formats = [
          "html"
          "json"
        ];
      };
      server = {
        secret_key = "@SECRET_KEY@";
        image_proxy = true;
        http_protocol_version = "1.0";
        method = "GET";
      };
      ui = {
        theme_args = {
          oscar_style = "pointhi";
        };
      };
      enabled_plugins = [
        "Open Access DOI rewrite"
        "Hash plugin"
        "HTTPS rewrite"
        "Self Informations"
        "Search on category select"
        "Tracker URL remover"
        "Vim-like hotkeys"
      ];
    };
  };

  systemd.services = {
    searx-init.personal.monitor = true;
    uwsgi.personal.monitor = true;
  };
}