Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Meilisearch service #626

Merged
merged 1 commit into from May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions examples/meilisearch/devenv.nix
@@ -0,0 +1,5 @@
{ ... }:

{
services.meilisearch.enable = true;
}
3 changes: 3 additions & 0 deletions examples/meilisearch/devenv.yaml
@@ -0,0 +1,3 @@
inputs:
nixpkgs:
url: github:NixOS/nixpkgs/nixpkgs-unstable
82 changes: 82 additions & 0 deletions src/modules/services/meilisearch.nix
@@ -0,0 +1,82 @@
{ pkgs, lib, config, ... }:

let
cfg = config.services.meilisearch;
types = lib.types;

in
{
options.services.meilisearch = {
enable = lib.mkEnableOption "Meilisearch";

listenAddress = lib.mkOption {
description = "Meilisearch listen address.";
default = "127.0.0.1";
type = types.str;
};

listenPort = lib.mkOption {
description = "Meilisearch port to listen on.";
default = 7700;
type = types.port;
};

environment = lib.mkOption {
description = "Defines the running environment of Meilisearch.";
default = "development";
type = types.enum [ "development" "production" ];
};

noAnalytics = lib.mkOption {
description = ''
Deactivates analytics.
Analytics allow Meilisearch to know how many users are using Meilisearch,
which versions and which platforms are used.
This process is entirely anonymous.
'';
default = true;
type = types.bool;
};

logLevel = lib.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 = lib.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;
};
};

config = lib.mkIf cfg.enable {
packages = [ pkgs.meilisearch ];

env.MEILI_DB_PATH = config.env.DEVENV_STATE + "/meilisearch";
env.MEILI_HTTP_ADDR = "${cfg.listenAddress}:${toString cfg.listenPort}";
env.MEILI_NO_ANALYTICS = toString cfg.noAnalytics;
env.MEILI_ENV = cfg.environment;
env.MEILI_DUMP_DIR = config.env.MEILI_DB_PATH + "/dumps";
env.MEILI_LOG_LEVEL = cfg.logLevel;
env.MEILI_MAX_INDEX_SIZE = cfg.maxIndexSize;

ankhers marked this conversation as resolved.
Show resolved Hide resolved
processes.meilisearch = {
exec = "${pkgs.meilisearch}/bin/meilisearch";
};
};
}