summary refs log tree commit diff
path: root/nixos/modules/services/search
diff options
context:
space:
mode:
authorhappysalada <raphael@megzari.com>2021-09-14 20:27:11 +0900
committerRaphael Megzari <raphael@megzari.com>2021-09-20 16:12:29 +0900
commitbdd04deff52fd6eb0d34e08ac8193ddb96c84a96 (patch)
tree6f0c4b45a85a8729eec417d3a18f87bb081d6416 /nixos/modules/services/search
parent6903737a8cab8e572ab28799377a28dd3785efa9 (diff)
downloadnixpkgs-bdd04deff52fd6eb0d34e08ac8193ddb96c84a96.tar
nixpkgs-bdd04deff52fd6eb0d34e08ac8193ddb96c84a96.tar.gz
nixpkgs-bdd04deff52fd6eb0d34e08ac8193ddb96c84a96.tar.bz2
nixpkgs-bdd04deff52fd6eb0d34e08ac8193ddb96c84a96.tar.lz
nixpkgs-bdd04deff52fd6eb0d34e08ac8193ddb96c84a96.tar.xz
nixpkgs-bdd04deff52fd6eb0d34e08ac8193ddb96c84a96.tar.zst
nixpkgs-bdd04deff52fd6eb0d34e08ac8193ddb96c84a96.zip
meilisearch: module cleanup
Diffstat (limited to 'nixos/modules/services/search')
-rw-r--r--nixos/modules/services/search/meilisearch.nix75
1 files changed, 59 insertions, 16 deletions
diff --git a/nixos/modules/services/search/meilisearch.nix b/nixos/modules/services/search/meilisearch.nix
index 9245bf68935..913a885993c 100644
--- a/nixos/modules/services/search/meilisearch.nix
+++ b/nixos/modules/services/search/meilisearch.nix
@@ -15,6 +15,13 @@ in
   options.services.meilisearch = {
     enable = mkEnableOption "MeiliSearch - a RESTful search API";
 
+    package = mkOption {
+      description = "The package to use for meilisearch. Use this if you require specific features to be enabled. The default package has no features.";
+      default = pkgs.meilisearch;
+      defaultText = "pkgs.meilisearch";
+      type = types.package;
+    };
+
     listenAddress = mkOption {
       description = "MeiliSearch listen address.";
       default = "127.0.0.1";
@@ -33,11 +40,14 @@ in
       type = types.enum [ "development" "production" ];
     };
 
-    masterKeyFile = mkOption {
+    # TODO change this to LoadCredentials once possible
+    masterKeyEnvironmentFile = mkOption {
       description = ''
         Path to file which contains the master key.
         By doing so, all routes will be protected and will require a key to be accessed.
         If no master key is provided, all routes can be accessed without requiring any key.
+        The format is the following:
+        MEILI_MASTER_KEY=my_secret_key
       '';
       default = null;
       type = with types; nullOr path;
@@ -50,10 +60,46 @@ in
         which versions and which platforms are used.
         This process is entirely anonymous.
       '';
-      default = false;
+      default = true;
       type = types.bool;
     };
 
+    logLevel = mkOption {
+      description = ''
+        Defines how much detail should be present in MeiliSearch's logs.
+        MeiliSearch currently supports four log levels, listed in order of increasing verbosity:
+        - 'ERROR': only log unexpected events indicating MeiliSearch is not functioning as expected
+        - 'WARN:' log all unexpected events, regardless of their severity
+        - 'INFO:' log all events. This is the default value
+        - 'DEBUG': log all events and including detailed information on MeiliSearch's internal processes.
+          Useful when diagnosing issues and debugging
+      '';
+      default = "INFO";
+      type = types.str;
+    };
+
+    maxIndexSize = mkOption {
+      description = ''
+        Sets the maximum size of the index.
+        Value must be given in bytes or explicitly stating a base unit.
+        For example, the default value can be written as 107374182400, '107.7Gb', or '107374 Mb'.
+        Default is 100 GiB
+      '';
+      default = "107374182400";
+      type = types.str;
+    };
+
+    payloadSizeLimit = mkOption {
+      description = ''
+        Sets the maximum size of accepted JSON payloads.
+        Value must be given in bytes or explicitly stating a base unit.
+        For example, the default value can be written as 107374182400, '107.7Gb', or '107374 Mb'.
+        Default is ~ 100 MB
+      '';
+      default = "104857600";
+      type = types.str;
+    };
+
   };
 
   ###### implementation
@@ -63,24 +109,21 @@ in
       description = "MeiliSearch daemon";
       wantedBy = [ "multi-user.target" ];
       after = [ "network.target" ];
-      environment =
-        let
-          masterKey = mkIf (cfg.masterKeyFile != null) (builtins.readFile cfg.masterKeyFile);
-        in
-        {
-          MEILI_DB_PATH = "/var/lib/meilisearch";
-          MEILI_HTTP_ADDR = "${cfg.listenAddress}:${toString cfg.listenPort}";
-          MEILI_MASTER_KEY = masterKey;
-          MEILI_NO_ANALYTICS = toString cfg.noAnalytics;
-          MEILI_ENV = cfg.environment;
-        };
+      environment = {
+        MEILI_DB_PATH = "/var/lib/meilisearch";
+        MEILI_HTTP_ADDR = "${cfg.listenAddress}:${toString cfg.listenPort}";
+        MEILI_NO_ANALYTICS = toString cfg.noAnalytics;
+        MEILI_ENV = cfg.environment;
+        MEILI_DUMPS_DIR = "/var/lib/meilisearch/dumps";
+        MEILI_LOG_LEVEL = cfg.logLevel;
+        MEILI_MAX_INDEX_SIZE = cfg.maxIndexSize;
+      };
       serviceConfig = {
-        ExecStart = "${pkgs.meilisearch}/bin/meilisearch";
+        ExecStart = "${cfg.package}/bin/meilisearch";
         DynamicUser = true;
         StateDirectory = "meilisearch";
+        EnvironmentFile = mkIf (cfg.masterKeyEnvironmentFile != null) cfg.masterKeyEnvironmentFile;
       };
     };
-
-    environment.systemPackages = [ pkgs.meilisearch ];
   };
 }