1 { config, lib, pkgs, ... }:
6 cfg = config.services.quickwit;
8 settingsFormat = pkgs.formats.yaml {};
9 quickwitYml = settingsFormat.generate "quickwit.yml" cfg.settings;
11 usingDefaultDataDir = cfg.dataDir == "/var/lib/quickwit";
12 usingDefaultUserAndGroup = cfg.user == "quickwit" && cfg.group == "quickwit";
16 options.services.quickwit = {
17 enable = mkEnableOption "Quickwit";
19 package = lib.mkPackageOption pkgs "Quickwit" {
20 default = [ "quickwit" ];
23 settings = lib.mkOption {
24 type = lib.types.submodule {
25 freeformType = settingsFormat.type;
27 options."rest" = lib.mkOption {
30 Rest server configuration for Quickwit
33 type = lib.types.submodule {
34 freeformType = settingsFormat.type;
36 options."listen_port" = lib.mkOption {
37 type = lib.types.port;
40 The port to listen on for HTTP REST traffic.
46 options."grpc_listen_port" = lib.mkOption {
47 type = lib.types.port;
50 The port to listen on for gRPC traffic.
54 options."listen_address" = lib.mkOption {
56 default = "127.0.0.1";
58 Listen address of Quickwit.
62 options."version" = lib.mkOption {
63 type = lib.types.float;
66 Configuration file version.
74 Quickwit configuration.
78 dataDir = lib.mkOption {
79 type = lib.types.path;
80 default = "/var/lib/quickwit";
81 apply = converge (removeSuffix "/");
83 Data directory for Quickwit. If you change this, you need to
84 manually create the directory. You also need to create the
85 `quickwit` user and group, or change
86 [](#opt-services.quickwit.user) and
87 [](#opt-services.quickwit.group) to existing ones with
88 access to the directory.
96 The user Quickwit runs as. Should be left at default unless
97 you have very specific needs.
101 group = lib.mkOption {
102 type = lib.types.str;
103 default = "quickwit";
105 The group quickwit runs as. Should be left at default unless
106 you have very specific needs.
110 extraFlags = lib.mkOption {
111 description = "Extra command line options to pass to Quickwit.";
113 type = lib.types.listOf lib.types.str;
116 restartIfChanged = lib.mkOption {
117 type = lib.types.bool;
119 Automatically restart the service on config change.
120 This can be set to false to defer restarts on a server or cluster.
121 Please consider the security implications of inadvertently running an older version,
122 and the possibility of unexpected behavior caused by inconsistent versions across a cluster when disabling this option.
128 config = mkIf cfg.enable {
129 systemd.services.quickwit = {
130 description = "Quickwit";
131 wantedBy = [ "multi-user.target" ];
132 after = [ "network.target" ];
133 inherit (cfg) restartIfChanged;
135 QW_DATA_DIR = cfg.dataDir;
139 ${cfg.package}/bin/quickwit run --config ${quickwitYml} \
140 ${escapeShellArgs cfg.extraFlags}
144 Restart = "on-failure";
145 DynamicUser = usingDefaultUserAndGroup && usingDefaultDataDir;
146 CapabilityBoundingSet = [ "" ];
147 DevicePolicy = "closed";
148 LockPersonality = true;
149 MemoryDenyWriteExecute = true;
150 NoNewPrivileges = true;
151 PrivateDevices = true;
155 ProtectHostname = true;
156 ProtectControlGroups = true;
157 ProtectKernelLogs = true;
158 ProtectKernelModules = true;
159 ProtectKernelTunables = true;
160 ProtectProc = "invisible";
161 ProtectSystem = "strict";
165 RestrictAddressFamilies = [
170 RestrictNamespaces = true;
171 RestrictRealtime = true;
172 RestrictSUIDSGID = true;
173 SystemCallArchitectures = "native";
175 # 1. allow a reasonable set of syscalls
176 "@system-service @resources"
177 # 2. and deny unreasonable ones
179 # 3. then allow the required subset within denied groups
182 } // (optionalAttrs (usingDefaultDataDir) {
183 StateDirectory = "quickwit";
184 StateDirectoryMode = "0700";
188 environment.systemPackages = [ cfg.package ];