mirror of
https://github.com/juspay/services-flake.git
synced 2024-10-05 16:37:38 +03:00
feat(searxng): init (#241)
This commit is contained in:
parent
d16e7950ea
commit
f3098faecd
21
doc/searxng.md
Normal file
21
doc/searxng.md
Normal 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";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
@ -31,7 +31,7 @@
|
|||||||
dataDir = "${dataDirBase}/ollama1";
|
dataDir = "${dataDirBase}/ollama1";
|
||||||
|
|
||||||
# Define the models to download when our app starts
|
# Define the models to download when our app starts
|
||||||
#
|
#
|
||||||
# You can also initialize this to empty list, and download the
|
# You can also initialize this to empty list, and download the
|
||||||
# models manually in the UI.
|
# models manually in the UI.
|
||||||
#
|
#
|
||||||
|
@ -21,5 +21,6 @@ in
|
|||||||
./cassandra.nix
|
./cassandra.nix
|
||||||
./tempo.nix
|
./tempo.nix
|
||||||
./weaviate.nix
|
./weaviate.nix
|
||||||
|
./searxng.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
83
nix/searxng.nix
Normal file
83
nix/searxng.nix
Normal 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
22
nix/searxng_test.nix
Normal 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";
|
||||||
|
};
|
||||||
|
}
|
@ -52,6 +52,8 @@
|
|||||||
] ++ lib.optionals pkgs.stdenv.isLinux [
|
] ++ lib.optionals pkgs.stdenv.isLinux [
|
||||||
# Broken on Darwin: https://github.com/NixOS/nixpkgs/issues/316954
|
# Broken on Darwin: https://github.com/NixOS/nixpkgs/issues/316954
|
||||||
"${inputs.services-flake}/nix/grafana_test.nix"
|
"${inputs.services-flake}/nix/grafana_test.nix"
|
||||||
|
# Broken on Darwin: https://github.com/NixOS/nixpkgs/issues/321329
|
||||||
|
"${inputs.services-flake}/nix/searxng_test.nix"
|
||||||
]));
|
]));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user