mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 04:05:40 +03:00
nixos/searx: reformat tests with nixfmt-rfc-style
This commit is contained in:
parent
931b1bb0f1
commit
da9d79d6bc
1 changed files with 85 additions and 81 deletions
|
@ -1,4 +1,4 @@
|
||||||
{ pkgs, ...} :
|
{ pkgs, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
name = "searx";
|
name = "searx";
|
||||||
|
@ -7,104 +7,108 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
# basic setup: searx running the built-in webserver
|
# basic setup: searx running the built-in webserver
|
||||||
nodes.base = { ... }: {
|
nodes.base =
|
||||||
services.searx = {
|
{ ... }:
|
||||||
enable = true;
|
{
|
||||||
environmentFile = pkgs.writeText "secrets" ''
|
services.searx = {
|
||||||
WOLFRAM_API_KEY = sometoken
|
enable = true;
|
||||||
SEARX_SECRET_KEY = somesecret
|
environmentFile = pkgs.writeText "secrets" ''
|
||||||
'';
|
WOLFRAM_API_KEY = sometoken
|
||||||
|
SEARX_SECRET_KEY = somesecret
|
||||||
|
'';
|
||||||
|
|
||||||
settings.server =
|
settings.server = {
|
||||||
{ port = "8080";
|
port = "8080";
|
||||||
bind_address = "0.0.0.0";
|
bind_address = "0.0.0.0";
|
||||||
secret_key = "@SEARX_SECRET_KEY@";
|
secret_key = "@SEARX_SECRET_KEY@";
|
||||||
};
|
};
|
||||||
settings.engines = [
|
settings.engines = [
|
||||||
{ name = "wolframalpha";
|
{
|
||||||
api_key = "@WOLFRAM_API_KEY@";
|
name = "wolframalpha";
|
||||||
engine = "wolframalpha_api";
|
api_key = "@WOLFRAM_API_KEY@";
|
||||||
}
|
engine = "wolframalpha_api";
|
||||||
{ name = "startpage";
|
}
|
||||||
shortcut = "start";
|
{
|
||||||
}
|
name = "startpage";
|
||||||
];
|
shortcut = "start";
|
||||||
};
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# fancy setup: run in uWSGI and use nginx as proxy
|
# fancy setup: run in uWSGI and use nginx as proxy
|
||||||
nodes.fancy = { config, ... }: {
|
nodes.fancy =
|
||||||
services.searx = {
|
{ config, ... }:
|
||||||
enable = true;
|
{
|
||||||
# searx refuses to run if unchanged
|
services.searx = {
|
||||||
settings.server.secret_key = "somesecret";
|
enable = true;
|
||||||
|
# searx refuses to run if unchanged
|
||||||
|
settings.server.secret_key = "somesecret";
|
||||||
|
|
||||||
runInUwsgi = true;
|
runInUwsgi = true;
|
||||||
uwsgiConfig = {
|
uwsgiConfig = {
|
||||||
# serve using the uwsgi protocol
|
# serve using the uwsgi protocol
|
||||||
socket = "/run/searx/uwsgi.sock";
|
socket = "/run/searx/uwsgi.sock";
|
||||||
chmod-socket = "660";
|
chmod-socket = "660";
|
||||||
|
|
||||||
# use /searx as url "mountpoint"
|
# use /searx as url "mountpoint"
|
||||||
mount = "/searx=searx.webapp:application";
|
mount = "/searx=searx.webapp:application";
|
||||||
module = "";
|
module = "";
|
||||||
manage-script-name = true;
|
manage-script-name = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
# use nginx as reverse proxy
|
# use nginx as reverse proxy
|
||||||
services.nginx.enable = true;
|
services.nginx.enable = true;
|
||||||
services.nginx.virtualHosts.localhost = {
|
services.nginx.virtualHosts.localhost = {
|
||||||
locations."/searx".extraConfig =
|
locations."/searx".extraConfig = ''
|
||||||
''
|
|
||||||
include ${pkgs.nginx}/conf/uwsgi_params;
|
include ${pkgs.nginx}/conf/uwsgi_params;
|
||||||
uwsgi_pass unix:/run/searx/uwsgi.sock;
|
uwsgi_pass unix:/run/searx/uwsgi.sock;
|
||||||
'';
|
'';
|
||||||
locations."/searx/static/".alias = "${config.services.searx.package}/share/static/";
|
locations."/searx/static/".alias = "${config.services.searx.package}/share/static/";
|
||||||
|
};
|
||||||
|
|
||||||
|
# allow nginx access to the searx socket
|
||||||
|
users.users.nginx.extraGroups = [ "searx" ];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# allow nginx access to the searx socket
|
testScript = ''
|
||||||
users.users.nginx.extraGroups = [ "searx" ];
|
base.start()
|
||||||
|
|
||||||
};
|
with subtest("Settings have been merged"):
|
||||||
|
base.wait_for_unit("searx-init")
|
||||||
|
base.wait_for_file("/run/searx/settings.yml")
|
||||||
|
output = base.succeed(
|
||||||
|
"${pkgs.yq-go}/bin/yq eval"
|
||||||
|
" '.engines[] | select(.name==\"startpage\") | .shortcut'"
|
||||||
|
" /run/searx/settings.yml"
|
||||||
|
).strip()
|
||||||
|
assert output == "start", "Settings not merged"
|
||||||
|
|
||||||
testScript =
|
with subtest("Environment variables have been substituted"):
|
||||||
''
|
base.succeed("grep -q somesecret /run/searx/settings.yml")
|
||||||
base.start()
|
base.succeed("grep -q sometoken /run/searx/settings.yml")
|
||||||
|
base.copy_from_vm("/run/searx/settings.yml")
|
||||||
|
|
||||||
with subtest("Settings have been merged"):
|
with subtest("Basic setup is working"):
|
||||||
base.wait_for_unit("searx-init")
|
base.wait_for_open_port(8080)
|
||||||
base.wait_for_file("/run/searx/settings.yml")
|
base.wait_for_unit("searx")
|
||||||
output = base.succeed(
|
base.succeed(
|
||||||
"${pkgs.yq-go}/bin/yq eval"
|
"${pkgs.curl}/bin/curl --fail http://localhost:8080"
|
||||||
" '.engines[] | select(.name==\"startpage\") | .shortcut'"
|
)
|
||||||
" /run/searx/settings.yml"
|
base.shutdown()
|
||||||
).strip()
|
|
||||||
assert output == "start", "Settings not merged"
|
|
||||||
|
|
||||||
with subtest("Environment variables have been substituted"):
|
with subtest("Nginx+uWSGI setup is working"):
|
||||||
base.succeed("grep -q somesecret /run/searx/settings.yml")
|
fancy.start()
|
||||||
base.succeed("grep -q sometoken /run/searx/settings.yml")
|
fancy.wait_for_open_port(80)
|
||||||
base.copy_from_vm("/run/searx/settings.yml")
|
fancy.wait_for_unit("uwsgi")
|
||||||
|
fancy.succeed(
|
||||||
with subtest("Basic setup is working"):
|
"${pkgs.curl}/bin/curl --fail http://localhost/searx >&2"
|
||||||
base.wait_for_open_port(8080)
|
)
|
||||||
base.wait_for_unit("searx")
|
fancy.succeed(
|
||||||
base.succeed(
|
"${pkgs.curl}/bin/curl --fail http://localhost/searx/static/themes/simple/js/leaflet.js >&2"
|
||||||
"${pkgs.curl}/bin/curl --fail http://localhost:8080"
|
)
|
||||||
)
|
'';
|
||||||
base.shutdown()
|
|
||||||
|
|
||||||
with subtest("Nginx+uWSGI setup is working"):
|
|
||||||
fancy.start()
|
|
||||||
fancy.wait_for_open_port(80)
|
|
||||||
fancy.wait_for_unit("uwsgi")
|
|
||||||
fancy.succeed(
|
|
||||||
"${pkgs.curl}/bin/curl --fail http://localhost/searx >&2"
|
|
||||||
)
|
|
||||||
fancy.succeed(
|
|
||||||
"${pkgs.curl}/bin/curl --fail http://localhost/searx/static/themes/simple/js/leaflet.js >&2"
|
|
||||||
)
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue