1 { config, lib, pkgs, ... }:
7 cfg = config.services.manticore;
8 format = pkgs.formats.json { };
11 mkKeyValue ? mkKeyValueDefault {} "=",
12 listsAsDuplicateKeys ? true
15 # map function to string for each key val
16 mapAttrsToStringsSep = sep: mapFn: attrs:
18 (mapAttrsToList mapFn attrs);
19 mkSection = sectName: sectValues: ''
21 '' + lib.generators.toKeyValue { inherit mkKeyValue listsAsDuplicateKeys; } sectValues + ''}'';
23 # map input to ini sections
24 mapAttrsToStringsSep "\n" mkSection attrsOfAttrs;
26 configFile = pkgs.writeText "manticore.conf" (
28 mkKeyValue = k: v: " ${k} = ${v}";
35 services.manticore = {
37 enable = mkEnableOption "Manticoresearch";
44 "127.0.0.1:9306:mysql"
47 log = "/var/log/manticore/searchd.log";
48 query_log = "/var/log/manticore/query.log";
49 pid_file = "/run/manticore/searchd.pid";
50 data_dir = "/var/lib/manticore";
54 Configuration for Manticoresearch. See
55 <https://manual.manticoresearch.com/Server%20settings>
58 type = types.submodule {
59 freeformType = format.type;
61 example = literalExpression ''
66 "127.0.0.1:9306:mysql"
69 log = "/var/log/manticore/searchd.log";
70 query_log = "/var/log/manticore/query.log";
71 pid_file = "/run/manticore/searchd.pid";
72 data_dir = "/var/lib/manticore";
81 config = mkIf cfg.enable {
84 packages = [ pkgs.manticoresearch ];
85 services.manticore = {
86 wantedBy = [ "multi-user.target" ];
87 after = [ "network.target" ];
91 "${pkgs.manticoresearch}/bin/searchd --config ${configFile}"
95 "${pkgs.manticoresearch}/bin/searchd --config ${configFile} --stopwait"
97 ExecStartPre = [ "" ];
99 LogsDirectory = "manticore";
100 RuntimeDirectory = "manticore";
101 StateDirectory = "manticore";
103 CapabilityBoundingSet = "";
104 RestrictAddressFamilies = [ "AF_UNIX" "AF_INET" "AF_INET6" ];
105 RestrictNamespaces = true;
106 PrivateDevices = true;
109 ProtectControlGroups = true;
111 ProtectKernelLogs = true;
112 ProtectKernelModules = true;
113 ProtectKernelTunables = true;
114 SystemCallArchitectures = "native";
115 SystemCallFilter = [ "@system-service" "~@privileged" ];
116 RestrictRealtime = true;
117 LockPersonality = true;
118 MemoryDenyWriteExecute = true;
120 ProtectHostname = true;
121 } // lib.optionalAttrs (cfg.settings.searchd.pid_file != null) {
122 PIDFile = cfg.settings.searchd.pid_file;
129 meta.maintainers = with lib.maintainers; [ onny ];