Merge pull request #266675 from anthonyroussel/sonic-server-nixos

nixos/sonic-server: init
This commit is contained in:
Mario Rodas 2023-11-25 23:45:16 -05:00 committed by GitHub
commit 1744e3fa01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 103 additions and 0 deletions

View file

@ -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

View 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";
};
};
};
}

View file

@ -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 {};

View 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]}'"
'';
})

View file

@ -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;