lol

nixos/searx: reformat tests with `nixfmt-rfc-style`

+84 -80
+84 -80
nixos/tests/searx.nix
··· 1 - { pkgs, ...} : 1 + { pkgs, ... }: 2 2 3 3 { 4 4 name = "searx"; ··· 7 7 }; 8 8 9 9 # basic setup: searx running the built-in webserver 10 - nodes.base = { ... }: { 11 - services.searx = { 12 - enable = true; 13 - environmentFile = pkgs.writeText "secrets" '' 14 - WOLFRAM_API_KEY = sometoken 15 - SEARX_SECRET_KEY = somesecret 16 - ''; 10 + nodes.base = 11 + { ... }: 12 + { 13 + services.searx = { 14 + enable = true; 15 + environmentFile = pkgs.writeText "secrets" '' 16 + WOLFRAM_API_KEY = sometoken 17 + SEARX_SECRET_KEY = somesecret 18 + ''; 17 19 18 - settings.server = 19 - { port = "8080"; 20 + settings.server = { 21 + port = "8080"; 20 22 bind_address = "0.0.0.0"; 21 23 secret_key = "@SEARX_SECRET_KEY@"; 22 24 }; 23 - settings.engines = [ 24 - { name = "wolframalpha"; 25 - api_key = "@WOLFRAM_API_KEY@"; 26 - engine = "wolframalpha_api"; 27 - } 28 - { name = "startpage"; 29 - shortcut = "start"; 30 - } 31 - ]; 32 - }; 25 + settings.engines = [ 26 + { 27 + name = "wolframalpha"; 28 + api_key = "@WOLFRAM_API_KEY@"; 29 + engine = "wolframalpha_api"; 30 + } 31 + { 32 + name = "startpage"; 33 + shortcut = "start"; 34 + } 35 + ]; 36 + }; 33 37 34 - }; 38 + }; 35 39 36 40 # fancy setup: run in uWSGI and use nginx as proxy 37 - nodes.fancy = { config, ... }: { 38 - services.searx = { 39 - enable = true; 40 - # searx refuses to run if unchanged 41 - settings.server.secret_key = "somesecret"; 41 + nodes.fancy = 42 + { config, ... }: 43 + { 44 + services.searx = { 45 + enable = true; 46 + # searx refuses to run if unchanged 47 + settings.server.secret_key = "somesecret"; 42 48 43 - runInUwsgi = true; 44 - uwsgiConfig = { 45 - # serve using the uwsgi protocol 46 - socket = "/run/searx/uwsgi.sock"; 47 - chmod-socket = "660"; 49 + runInUwsgi = true; 50 + uwsgiConfig = { 51 + # serve using the uwsgi protocol 52 + socket = "/run/searx/uwsgi.sock"; 53 + chmod-socket = "660"; 48 54 49 - # use /searx as url "mountpoint" 50 - mount = "/searx=searx.webapp:application"; 51 - module = ""; 52 - manage-script-name = true; 55 + # use /searx as url "mountpoint" 56 + mount = "/searx=searx.webapp:application"; 57 + module = ""; 58 + manage-script-name = true; 59 + }; 53 60 }; 54 - }; 55 61 56 - # use nginx as reverse proxy 57 - services.nginx.enable = true; 58 - services.nginx.virtualHosts.localhost = { 59 - locations."/searx".extraConfig = 60 - '' 62 + # use nginx as reverse proxy 63 + services.nginx.enable = true; 64 + services.nginx.virtualHosts.localhost = { 65 + locations."/searx".extraConfig = '' 61 66 include ${pkgs.nginx}/conf/uwsgi_params; 62 67 uwsgi_pass unix:/run/searx/uwsgi.sock; 63 68 ''; 64 - locations."/searx/static/".alias = "${config.services.searx.package}/share/static/"; 65 - }; 69 + locations."/searx/static/".alias = "${config.services.searx.package}/share/static/"; 70 + }; 66 71 67 - # allow nginx access to the searx socket 68 - users.users.nginx.extraGroups = [ "searx" ]; 72 + # allow nginx access to the searx socket 73 + users.users.nginx.extraGroups = [ "searx" ]; 69 74 70 - }; 75 + }; 71 76 72 - testScript = 73 - '' 74 - base.start() 77 + testScript = '' 78 + base.start() 75 79 76 - with subtest("Settings have been merged"): 77 - base.wait_for_unit("searx-init") 78 - base.wait_for_file("/run/searx/settings.yml") 79 - output = base.succeed( 80 - "${pkgs.yq-go}/bin/yq eval" 81 - " '.engines[] | select(.name==\"startpage\") | .shortcut'" 82 - " /run/searx/settings.yml" 83 - ).strip() 84 - assert output == "start", "Settings not merged" 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" 87 + ).strip() 88 + assert output == "start", "Settings not merged" 85 89 86 - with subtest("Environment variables have been substituted"): 87 - base.succeed("grep -q somesecret /run/searx/settings.yml") 88 - base.succeed("grep -q sometoken /run/searx/settings.yml") 89 - base.copy_from_vm("/run/searx/settings.yml") 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") 90 94 91 - with subtest("Basic setup is working"): 92 - base.wait_for_open_port(8080) 93 - base.wait_for_unit("searx") 94 - base.succeed( 95 - "${pkgs.curl}/bin/curl --fail http://localhost:8080" 96 - ) 97 - base.shutdown() 95 + with subtest("Basic setup is working"): 96 + base.wait_for_open_port(8080) 97 + base.wait_for_unit("searx") 98 + base.succeed( 99 + "${pkgs.curl}/bin/curl --fail http://localhost:8080" 100 + ) 101 + base.shutdown() 98 102 99 - with subtest("Nginx+uWSGI setup is working"): 100 - fancy.start() 101 - fancy.wait_for_open_port(80) 102 - fancy.wait_for_unit("uwsgi") 103 - fancy.succeed( 104 - "${pkgs.curl}/bin/curl --fail http://localhost/searx >&2" 105 - ) 106 - fancy.succeed( 107 - "${pkgs.curl}/bin/curl --fail http://localhost/searx/static/themes/simple/js/leaflet.js >&2" 108 - ) 109 - ''; 103 + with subtest("Nginx+uWSGI setup is working"): 104 + fancy.start() 105 + fancy.wait_for_open_port(80) 106 + fancy.wait_for_unit("uwsgi") 107 + fancy.succeed( 108 + "${pkgs.curl}/bin/curl --fail http://localhost/searx >&2" 109 + ) 110 + fancy.succeed( 111 + "${pkgs.curl}/bin/curl --fail http://localhost/searx/static/themes/simple/js/leaflet.js >&2" 112 + ) 113 + ''; 110 114 }