lol

nixos/mastodon: update elasticsearch configuration

authored by

Izorkin and committed by
Kerstin
63ed35da c5322227

+31 -2
+31 -2
nixos/modules/services/web-apps/mastodon.nix
··· 30 30 PAPERCLIP_ROOT_PATH = "/var/lib/mastodon/public-system"; 31 31 PAPERCLIP_ROOT_URL = "/system"; 32 32 ES_ENABLED = if (cfg.elasticsearch.host != null) then "true" else "false"; 33 - ES_HOST = cfg.elasticsearch.host; 34 - ES_PORT = toString(cfg.elasticsearch.port); 35 33 36 34 TRUSTED_PROXY_IP = cfg.trustedProxy; 37 35 } 38 36 // lib.optionalAttrs (cfg.database.host != "/run/postgresql" && cfg.database.port != null) { DB_PORT = toString cfg.database.port; } 39 37 // lib.optionalAttrs cfg.smtp.authenticate { SMTP_LOGIN = cfg.smtp.user; } 38 + // lib.optionalAttrs (cfg.elasticsearch.host != null) { ES_HOST = cfg.elasticsearch.host; } 39 + // lib.optionalAttrs (cfg.elasticsearch.host != null) { ES_PORT = toString(cfg.elasticsearch.port); } 40 + // lib.optionalAttrs (cfg.elasticsearch.host != null) { ES_PRESET = cfg.elasticsearch.preset; } 41 + // lib.optionalAttrs (cfg.elasticsearch.user != null) { ES_USER = cfg.elasticsearch.user; } 40 42 // cfg.extraConfig; 41 43 42 44 systemCallsList = [ "@cpu-emulation" "@debug" "@keyring" "@ipc" "@mount" "@obsolete" "@privileged" "@setuid" ]; ··· 513 515 type = lib.types.port; 514 516 default = 9200; 515 517 }; 518 + 519 + preset = lib.mkOption { 520 + description = lib.mdDoc '' 521 + It controls the ElasticSearch indices configuration (number of shards and replica). 522 + ''; 523 + type = lib.types.enum [ "single_node_cluster" "small_cluster" "large_cluster" ]; 524 + default = "single_node_cluster"; 525 + example = "large_cluster"; 526 + }; 527 + 528 + user = lib.mkOption { 529 + description = lib.mdDoc "Used for optionally authenticating with Elasticsearch."; 530 + type = lib.types.nullOr lib.types.str; 531 + default = null; 532 + example = "elasticsearch-mastodon"; 533 + }; 534 + 535 + passwordFile = lib.mkOption { 536 + description = lib.mdDoc '' 537 + Path to file containing password for optionally authenticating with Elasticsearch. 538 + ''; 539 + type = lib.types.nullOr lib.types.path; 540 + default = null; 541 + example = "/var/lib/mastodon/secrets/elasticsearch-password"; 542 + }; 516 543 }; 517 544 518 545 package = lib.mkOption { ··· 665 692 DB_PASS="$(cat ${cfg.database.passwordFile})" 666 693 '' + lib.optionalString cfg.smtp.authenticate '' 667 694 SMTP_PASSWORD="$(cat ${cfg.smtp.passwordFile})" 695 + '' + lib.optionalString (cfg.elasticsearch.passwordFile != null) '' 696 + ES_PASS="$(cat ${cfg.elasticsearch.passwordFile})" 668 697 '' + '' 669 698 EOF 670 699 '';