Skip to content

Commit

Permalink
searxng: init
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Jun 19, 2024
1 parent 647bff2 commit ebf9ccf
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 0 deletions.
20 changes: 20 additions & 0 deletions doc/searxng.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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;
settings = {
use_default_settings = true;
server.port = 1234;
server.bind_address = "127.0.0.1";
server.secret_key = "foobar";
};
};
}
```
1 change: 1 addition & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ in
./cassandra.nix
./tempo.nix
./weaviate.nix
./searxng.nix
];
}
73 changes: 73 additions & 0 deletions nix/searxng.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
pkgs,
lib,
name,
config,
...
}:
let
inherit (lib) types;

settingType =
with types;
(oneOf [
bool
int
float
str
(listOf settingType)
(attrsOf settingType)
])
// {
description = "JSON value";
};
in
{
options = {
enable = lib.mkEnableOption name;
package = lib.mkPackageOption pkgs "searxng" { };

settings = lib.mkOption {
type = types.attrsOf settingType;
default = {
use_default_settings = true;
server.port = 8080;
server.bind_address = "127.0.0.1";
server.secret_key = "secret";
server.limiter = false;
};
example = lib.literalExpression ''
{
use_default_settings = true;
server.port = 8080;
server.bind_address = "127.0.0.1";
server.secret_key = "secret";
}
'';
description = ''
Searxng settings. These will be merged with (taking precedence over)
the default configuration. It's also possible to refer to
environment variables using the syntax `@VARIABLE_NAME@`.
'';
};

outputs.settings = lib.mkOption {
type = types.deferredModule;
internal = true;
readOnly = true;
default = {
processes = {
"${name}" =
{
environment = {
SEARXNG_SETTINGS_PATH = "${pkgs.writeText "settings.yml" (builtins.toJSON config.settings)}";
};
command = lib.getExe config.package;
namespace = name;
availability.restart = "on_failure";
};
};
};
};
};
}
15 changes: 15 additions & 0 deletions nix/searxng_test.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{ pkgs, ... }:
{
services.searxng."searxng1".enable = true;

settings.processes.test = {
command = pkgs.writeShellApplication {
runtimeInputs = [ pkgs.curl ];
text = ''
curl http://127.0.0.1:8080
'';
name = "searxng-test";
};
depends_on."searxng".condition = "process_healthy";
};
}
1 change: 1 addition & 0 deletions test/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"${inputs.services-flake}/nix/cassandra_test.nix"
"${inputs.services-flake}/nix/tempo_test.nix"
"${inputs.services-flake}/nix/weaviate_test.nix"
"${inputs.services-flake}/nix/searxng_test.nix"
] ++ lib.optionals pkgs.stdenv.isLinux [
# Broken on Darwin: https://github.com/NixOS/nixpkgs/issues/316954
"${inputs.services-flake}/nix/grafana_test.nix"
Expand Down

0 comments on commit ebf9ccf

Please sign in to comment.