diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2023-11-26 06:01:19 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-26 06:01:19 +0000 |
commit | 4069806fb6f0e457266dc1cd4de2dfb4989f9197 (patch) | |
tree | 31957584464a8f9175b183bd89f50c26fc5578d7 /nixos/modules/services/search/sonic-server.nix | |
parent | dc40324f5959753fee712e78e1a43c2275c6e759 (diff) | |
parent | b6eefb4ac4b96a81d6c63027f2ea7a40ebe3559d (diff) | |
download | nixlib-4069806fb6f0e457266dc1cd4de2dfb4989f9197.tar nixlib-4069806fb6f0e457266dc1cd4de2dfb4989f9197.tar.gz nixlib-4069806fb6f0e457266dc1cd4de2dfb4989f9197.tar.bz2 nixlib-4069806fb6f0e457266dc1cd4de2dfb4989f9197.tar.lz nixlib-4069806fb6f0e457266dc1cd4de2dfb4989f9197.tar.xz nixlib-4069806fb6f0e457266dc1cd4de2dfb4989f9197.tar.zst nixlib-4069806fb6f0e457266dc1cd4de2dfb4989f9197.zip |
Merge staging-next into staging
Diffstat (limited to 'nixos/modules/services/search/sonic-server.nix')
-rw-r--r-- | nixos/modules/services/search/sonic-server.nix | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/nixos/modules/services/search/sonic-server.nix b/nixos/modules/services/search/sonic-server.nix new file mode 100644 index 000000000000..ac186260fa97 --- /dev/null +++ b/nixos/modules/services/search/sonic-server.nix @@ -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"; + }; + }; + }; +} |