From 4ec6492b3b2ec896035801b7b090dccc4b5ba797 Mon Sep 17 00:00:00 2001 From: Izorkin Date: Thu, 8 May 2025 12:32:42 +0300 Subject: [PATCH] nixos/mastodon: add option elasticsearch.prefix --- nixos/modules/services/web-apps/mastodon.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/nixos/modules/services/web-apps/mastodon.nix b/nixos/modules/services/web-apps/mastodon.nix index 80352fc4c920..da6a09a00101 100644 --- a/nixos/modules/services/web-apps/mastodon.nix +++ b/nixos/modules/services/web-apps/mastodon.nix @@ -55,6 +55,9 @@ let // lib.optionalAttrs cfg.smtp.authenticate { SMTP_LOGIN = cfg.smtp.user; } // lib.optionalAttrs (cfg.elasticsearch.host != null) { ES_HOST = cfg.elasticsearch.host; } // lib.optionalAttrs (cfg.elasticsearch.host != null) { ES_PORT = toString cfg.elasticsearch.port; } + // lib.optionalAttrs (cfg.elasticsearch.host != null && cfg.elasticsearch.prefix != null) { + ES_PREFIX = cfg.elasticsearch.prefix; + } // lib.optionalAttrs (cfg.elasticsearch.host != null) { ES_PRESET = cfg.elasticsearch.preset; } // lib.optionalAttrs (cfg.elasticsearch.user != null) { ES_USER = cfg.elasticsearch.user; } // cfg.extraConfig; @@ -670,6 +673,16 @@ in default = 9200; }; + prefix = lib.mkOption { + description = '' + If provided, adds a prefix to indexes in Elasticsearch. This allows to use the same + Elasticsearch cluster between different projects or Mastodon servers. + ''; + type = lib.types.nullOr lib.types.str; + default = null; + example = "mastodon"; + }; + preset = lib.mkOption { description = '' It controls the ElasticSearch indices configuration (number of shards and replica).