Merge pull request #266675 from anthonyroussel/sonic-server-nixos
nixos/sonic-server: init
This commit is contained in:
commit
1744e3fa01
5 changed files with 103 additions and 0 deletions
|
@ -1153,6 +1153,7 @@
|
|||
./services/search/meilisearch.nix
|
||||
./services/search/opensearch.nix
|
||||
./services/search/qdrant.nix
|
||||
./services/search/sonic-server.nix
|
||||
./services/search/typesense.nix
|
||||
./services/security/aesmd.nix
|
||||
./services/security/authelia.nix
|
||||
|
|
77
nixos/modules/services/search/sonic-server.nix
Normal file
77
nixos/modules/services/search/sonic-server.nix
Normal file
|
@ -0,0 +1,77 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.services.sonic-server;
|
||||
|
||||
settingsFormat = pkgs.formats.toml { };
|
||||
configFile = settingsFormat.generate "sonic-server-config.toml" cfg.settings;
|
||||
|
||||
in {
|
||||
meta.maintainers = [ lib.maintainers.anthonyroussel ];
|
||||
|
||||
options = {
|
||||
services.sonic-server = {
|
||||
enable = lib.mkEnableOption (lib.mdDoc "Sonic Search Index");
|
||||
|
||||
package = lib.mkPackageOptionMD pkgs "sonic-server" { };
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = lib.types.submodule { freeformType = settingsFormat.type; };
|
||||
default = {
|
||||
store.kv.path = "/var/lib/sonic/kv";
|
||||
store.fst.path = "/var/lib/sonic/fst";
|
||||
};
|
||||
example = {
|
||||
server.log_level = "debug";
|
||||
channel.inet = "[::1]:1491";
|
||||
};
|
||||
description = lib.mdDoc ''
|
||||
Sonic Server configuration options.
|
||||
|
||||
Refer to
|
||||
<https://github.com/valeriansaliou/sonic/blob/master/CONFIGURATION.md>
|
||||
for a full list of available options.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.sonic-server.settings = lib.mapAttrs (name: lib.mkDefault) {
|
||||
server = {};
|
||||
channel.search = {};
|
||||
store = {
|
||||
kv = {
|
||||
path = "/var/lib/sonic/kv";
|
||||
database = {};
|
||||
pool = {};
|
||||
};
|
||||
fst = {
|
||||
path = "/var/lib/sonic/fst";
|
||||
graph = {};
|
||||
pool = {};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.sonic-server = {
|
||||
description = "Sonic Search Index";
|
||||
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
|
||||
ExecStart = "${lib.getExe cfg.package} -c ${configFile}";
|
||||
DynamicUser = true;
|
||||
Group = "sonic";
|
||||
LimitNOFILE = "infinity";
|
||||
Restart = "on-failure";
|
||||
StateDirectory = "sonic";
|
||||
StateDirectoryMode = "750";
|
||||
User = "sonic";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -766,6 +766,7 @@ in {
|
|||
sogo = handleTest ./sogo.nix {};
|
||||
solanum = handleTest ./solanum.nix {};
|
||||
sonarr = handleTest ./sonarr.nix {};
|
||||
sonic-server = handleTest ./sonic-server.nix {};
|
||||
sourcehut = handleTest ./sourcehut.nix {};
|
||||
spacecookie = handleTest ./spacecookie.nix {};
|
||||
spark = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./spark {};
|
||||
|
|
22
nixos/tests/sonic-server.nix
Normal file
22
nixos/tests/sonic-server.nix
Normal file
|
@ -0,0 +1,22 @@
|
|||
import ./make-test-python.nix ({ pkgs, lib, ... }: {
|
||||
name = "sonic-server";
|
||||
|
||||
meta = {
|
||||
maintainers = with lib.maintainers; [ anthonyroussel ];
|
||||
};
|
||||
|
||||
nodes.machine = { pkgs, ... }: {
|
||||
services.sonic-server.enable = true;
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
machine.start()
|
||||
|
||||
machine.wait_for_unit("sonic-server.service")
|
||||
machine.wait_for_open_port(1491)
|
||||
|
||||
with subtest("Check control mode"):
|
||||
result = machine.succeed('(echo START control; sleep 1; echo PING; echo QUIT) | nc localhost 1491').splitlines()
|
||||
assert result[2] == "PONG", f"expected 'PONG', got '{result[2]}'"
|
||||
'';
|
||||
})
|
|
@ -2,6 +2,7 @@
|
|||
, rustPlatform
|
||||
, fetchFromGitHub
|
||||
, nix-update-script
|
||||
, nixosTests
|
||||
, testers
|
||||
, sonic-server
|
||||
}:
|
||||
|
@ -42,6 +43,7 @@ rustPlatform.buildRustPackage rec {
|
|||
|
||||
passthru = {
|
||||
tests = {
|
||||
inherit (nixosTests) sonic-server;
|
||||
version = testers.testVersion {
|
||||
command = "sonic --version";
|
||||
package = sonic-server;
|
||||
|
|
Loading…
Reference in a new issue