feat(searxng): init (#241)

This commit is contained in:
Pol Dellaiera 2024-06-20 22:08:45 +02:00 committed by GitHub
parent d16e7950ea
commit f3098faecd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 130 additions and 1 deletions

21
doc/searxng.md Normal file
View File

@ -0,0 +1,21 @@
# Searxng
[Searxng](https://github.com/searxng/searxng) is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
## Getting Started
```nix
# In `perSystem.process-compose.<name>`
{
services.searxng."instance-name" = {
enable = true;
port = 1234;
host = "127.0.0.1";
secret_key = "my-secret-key";
settings = {
doi_resolvers."dummy" = "http://example.org";
default_doi_resolver = "dummy";
};
};
}
```

View File

@ -31,7 +31,7 @@
dataDir = "${dataDirBase}/ollama1";
# Define the models to download when our app starts
#
#
# You can also initialize this to empty list, and download the
# models manually in the UI.
#

View File

@ -21,5 +21,6 @@ in
./cassandra.nix
./tempo.nix
./weaviate.nix
./searxng.nix
];
}

83
nix/searxng.nix Normal file
View File

@ -0,0 +1,83 @@
{ pkgs, lib, name, config, ... }:
let
inherit (lib) types;
yamlFormat = pkgs.formats.yaml { };
in
{
options = {
enable = lib.mkEnableOption name;
package = lib.mkPackageOption pkgs "searxng" { };
host = lib.mkOption {
description = "Searxng bind address";
default = "127.0.0.1";
type = types.str;
};
port = lib.mkOption {
description = "Searxng port to listen on";
default = 8080;
type = types.port;
};
use_default_settings = lib.mkOption {
description = "Use default Searxng settings";
default = true;
type = types.bool;
};
secret_key = lib.mkOption {
description = "Searxng secret key";
default = "secret";
example = "secret-key";
type = types.str;
};
settings = lib.mkOption {
type = yamlFormat.type;
default = { };
example = lib.literalExpression ''
{
doi_resolvers."dummy" = "http://example.org";
default_doi_resolver = "dummy";
}
'';
description = ''
Searxng settings
'';
};
outputs.settings = lib.mkOption {
type = types.deferredModule;
internal = true;
readOnly = true;
default = {
processes = {
"${name}" = {
environment = {
SEARXNG_SETTINGS_PATH = "${yamlFormat.generate "settings.yaml" (
lib.recursiveUpdate config.settings {
server.bind_address = config.host;
server.port = config.port;
server.secret_key = config.secret_key;
use_default_settings = config.use_default_settings;
}
)}";
};
command = lib.getExe config.package;
namespace = name;
availability.restart = "on_failure";
readiness_probe = {
exec.command = "${lib.getExe pkgs.curl} -f -k http://${config.host}:${toString config.port}";
initial_delay_seconds = 5;
period_seconds = 10;
timeout_seconds = 2;
success_threshold = 1;
failure_threshold = 5;
};
};
};
};
};
};
}

22
nix/searxng_test.nix Normal file
View File

@ -0,0 +1,22 @@
{ pkgs, ... }:
{
services.searxng."searxng1" = {
enable = true;
use_default_settings = false;
settings = {
doi_resolvers."dummy" = "http://example.org";
default_doi_resolver = "dummy";
};
};
settings.processes.test = {
command = pkgs.writeShellApplication {
runtimeInputs = [ pkgs.curl ];
text = ''
curl http://127.0.0.1:8080
'';
name = "searxng-test";
};
depends_on."searxng1".condition = "process_healthy";
};
}

View File

@ -52,6 +52,8 @@
] ++ lib.optionals pkgs.stdenv.isLinux [
# Broken on Darwin: https://github.com/NixOS/nixpkgs/issues/316954
"${inputs.services-flake}/nix/grafana_test.nix"
# Broken on Darwin: https://github.com/NixOS/nixpkgs/issues/321329
"${inputs.services-flake}/nix/searxng_test.nix"
]));
};
};