5 meta = with pkgs.lib.maintainers; {
6 maintainers = [ rnhmjoj ];
9 # basic setup: searx running the built-in webserver
15 environmentFile = pkgs.writeText "secrets" ''
16 WOLFRAM_API_KEY = sometoken
17 SEARX_SECRET_KEY = somesecret
22 bind_address = "0.0.0.0";
23 secret_key = "@SEARX_SECRET_KEY@";
27 name = "wolframalpha";
28 api_key = "@WOLFRAM_API_KEY@";
29 engine = "wolframalpha_api";
40 # fancy setup: run in uWSGI and use nginx as proxy
46 # searx refuses to run if unchanged
47 settings.server.secret_key = "somesecret";
51 # serve using the uwsgi protocol
52 socket = "/run/searx/uwsgi.sock";
55 # use /searx as url "mountpoint"
56 mount = "/searx=searx.webapp:application";
58 manage-script-name = true;
62 # use nginx as reverse proxy
63 services.nginx.enable = true;
64 services.nginx.virtualHosts.localhost = {
65 locations."/searx".extraConfig = ''
66 include ${pkgs.nginx}/conf/uwsgi_params;
67 uwsgi_pass unix:/run/searx/uwsgi.sock;
69 locations."/searx/static/".alias = "${config.services.searx.package}/share/static/";
72 # allow nginx access to the searx socket
73 users.users.nginx.extraGroups = [ "searx" ];
80 with subtest("Settings have been merged"):
81 base.wait_for_unit("searx-init")
82 base.wait_for_file("/run/searx/settings.yml")
83 output = base.succeed(
84 "${pkgs.yq-go}/bin/yq eval"
85 " '.engines[] | select(.name==\"startpage\") | .shortcut'"
86 " /run/searx/settings.yml"
88 assert output == "start", "Settings not merged"
90 with subtest("Environment variables have been substituted"):
91 base.succeed("grep -q somesecret /run/searx/settings.yml")
92 base.succeed("grep -q sometoken /run/searx/settings.yml")
93 base.copy_from_vm("/run/searx/settings.yml")
95 with subtest("Basic setup is working"):
96 base.wait_for_open_port(8080)
97 base.wait_for_unit("searx")
99 "${pkgs.curl}/bin/curl --fail http://localhost:8080"
103 with subtest("Nginx+uWSGI setup is working"):
105 fancy.wait_for_open_port(80)
106 fancy.wait_for_unit("uwsgi")
108 "${pkgs.curl}/bin/curl --fail http://localhost/searx >&2"
111 "${pkgs.curl}/bin/curl --fail http://localhost/searx/static/themes/simple/js/leaflet.js >&2"