Loading nixos/modules/services/web-apps/librechat.nix +34 −1 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ }: let cfg = config.services.librechat; meiliCfg = config.services.meilisearch; format = pkgs.formats.yaml { }; configFile = format.generate "librechat.yaml" cfg.settings; exportCredentials = n: _: ''export ${n}="$(${pkgs.systemd}/bin/systemd-creds cat ${n}_FILE)"''; Loading Loading @@ -155,6 +156,26 @@ in }; enableLocalDB = lib.mkEnableOption "a local mongodb instance"; meilisearch = lib.mkOption { type = lib.types.submodule { options = { enable = lib.mkOption { type = lib.types.bool; default = false; example = true; description = '' Whether to enable and configure Meilisearch locally for Librechat. You will manually need to set `services.meilisearch.masterKeyFile`. ''; }; }; }; default = { }; description = '' See [LibreChat search feature](https://www.librechat.ai/docs/features/search). ''; }; }; config = lib.mkIf cfg.enable { Loading @@ -178,6 +199,12 @@ in You can use https://www.librechat.ai/toolkit/creds_generator to generate these. ''; } { assertion = cfg.meilisearch.enable -> meiliCfg.masterKeyFile != null; message = '' LibreChat's Meilisearch integration requires `services.meilisearch.masterKeyFile` to be set. ''; } ]; networking.firewall.allowedTCPPorts = lib.optional cfg.openFirewall cfg.port; Loading @@ -192,7 +219,8 @@ in after = [ "tmpfiles.target" ] ++ lib.optional cfg.enableLocalDB "mongodb.service"; ++ lib.optional cfg.meilisearch.enable "meilisearch.service"; wants = lib.optional cfg.meilisearch.enable "meilisearch.service"; description = "Open-source app for all your AI conversations, fully customizable and compatible with any AI provider"; environment = cfg.env; script = # sh Loading Loading @@ -249,6 +277,11 @@ in services.librechat.env.MONGO_URI = lib.mkIf cfg.enableLocalDB "mongodb://localhost:27017"; services.mongodb.enable = lib.mkIf cfg.enableLocalDB true; services.meilisearch.enable = lib.mkIf cfg.meilisearch.enable true; services.librechat.env.SEARCH = lib.mkIf cfg.meilisearch.enable true; services.librechat.env.MEILI_HOST = lib.mkIf cfg.meilisearch.enable "http://${meiliCfg.settings.http_addr}"; services.librechat.credentials.MEILI_MASTER_KEY = lib.mkIf cfg.meilisearch.enable meiliCfg.masterKeyFile; }; meta.maintainers = with lib.maintainers; [ Loading nixos/tests/librechat.nix +7 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ credsIvFile = pkgs.writeText "librechat-creds-iv" "7c09a571f65ac793611685cc9ab1dbe7"; jwtSecret = pkgs.writeText "librechat-jwt-secret" "29c4dc7f7de15306accf5eddb4cb8a70eb233d9fba4301f8f47f14c8c047ac81"; jwtRefreshSecret = pkgs.writeText "librechat-jwt-refresh-secret" "f2c1685561f2f570b3e7955df267b5c602ee099f14dc5caa0dacc320580ea180"; meilisearchMasterKeyFile = pkgs.writeText "meilisearch-master-key" "xHkP3Bzcf98fw7FiSCR82g5ULLGrXc4frK1qkEfN8St/3kJZ"; in { services.librechat = { Loading @@ -32,13 +33,19 @@ JWT_REFRESH_SECRET = jwtRefreshSecret; }; enableLocalDB = true; meilisearch.enable = true; }; services.meilisearch.masterKeyFile = meilisearchMasterKeyFile; }; testScript = '' machine.start() machine.succeed("grep -qF 'ALLOW_REGISTRATION=true' /etc/systemd/system/librechat.service") machine.succeed("grep -qF 'SEARCH=true' /etc/systemd/system/librechat.service") machine.succeed("grep -qF 'MEILI_HOST=http://localhost:7700' /etc/systemd/system/librechat.service") machine.succeed("grep -qG 'MEILI_MASTER_KEY_FILE:/nix/store/.*meilisearch-master-key' /etc/systemd/system/librechat.service") machine.wait_for_unit("librechat.service") machine.wait_for_open_port(3080) Loading Loading
nixos/modules/services/web-apps/librechat.nix +34 −1 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ }: let cfg = config.services.librechat; meiliCfg = config.services.meilisearch; format = pkgs.formats.yaml { }; configFile = format.generate "librechat.yaml" cfg.settings; exportCredentials = n: _: ''export ${n}="$(${pkgs.systemd}/bin/systemd-creds cat ${n}_FILE)"''; Loading Loading @@ -155,6 +156,26 @@ in }; enableLocalDB = lib.mkEnableOption "a local mongodb instance"; meilisearch = lib.mkOption { type = lib.types.submodule { options = { enable = lib.mkOption { type = lib.types.bool; default = false; example = true; description = '' Whether to enable and configure Meilisearch locally for Librechat. You will manually need to set `services.meilisearch.masterKeyFile`. ''; }; }; }; default = { }; description = '' See [LibreChat search feature](https://www.librechat.ai/docs/features/search). ''; }; }; config = lib.mkIf cfg.enable { Loading @@ -178,6 +199,12 @@ in You can use https://www.librechat.ai/toolkit/creds_generator to generate these. ''; } { assertion = cfg.meilisearch.enable -> meiliCfg.masterKeyFile != null; message = '' LibreChat's Meilisearch integration requires `services.meilisearch.masterKeyFile` to be set. ''; } ]; networking.firewall.allowedTCPPorts = lib.optional cfg.openFirewall cfg.port; Loading @@ -192,7 +219,8 @@ in after = [ "tmpfiles.target" ] ++ lib.optional cfg.enableLocalDB "mongodb.service"; ++ lib.optional cfg.meilisearch.enable "meilisearch.service"; wants = lib.optional cfg.meilisearch.enable "meilisearch.service"; description = "Open-source app for all your AI conversations, fully customizable and compatible with any AI provider"; environment = cfg.env; script = # sh Loading Loading @@ -249,6 +277,11 @@ in services.librechat.env.MONGO_URI = lib.mkIf cfg.enableLocalDB "mongodb://localhost:27017"; services.mongodb.enable = lib.mkIf cfg.enableLocalDB true; services.meilisearch.enable = lib.mkIf cfg.meilisearch.enable true; services.librechat.env.SEARCH = lib.mkIf cfg.meilisearch.enable true; services.librechat.env.MEILI_HOST = lib.mkIf cfg.meilisearch.enable "http://${meiliCfg.settings.http_addr}"; services.librechat.credentials.MEILI_MASTER_KEY = lib.mkIf cfg.meilisearch.enable meiliCfg.masterKeyFile; }; meta.maintainers = with lib.maintainers; [ Loading
nixos/tests/librechat.nix +7 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ credsIvFile = pkgs.writeText "librechat-creds-iv" "7c09a571f65ac793611685cc9ab1dbe7"; jwtSecret = pkgs.writeText "librechat-jwt-secret" "29c4dc7f7de15306accf5eddb4cb8a70eb233d9fba4301f8f47f14c8c047ac81"; jwtRefreshSecret = pkgs.writeText "librechat-jwt-refresh-secret" "f2c1685561f2f570b3e7955df267b5c602ee099f14dc5caa0dacc320580ea180"; meilisearchMasterKeyFile = pkgs.writeText "meilisearch-master-key" "xHkP3Bzcf98fw7FiSCR82g5ULLGrXc4frK1qkEfN8St/3kJZ"; in { services.librechat = { Loading @@ -32,13 +33,19 @@ JWT_REFRESH_SECRET = jwtRefreshSecret; }; enableLocalDB = true; meilisearch.enable = true; }; services.meilisearch.masterKeyFile = meilisearchMasterKeyFile; }; testScript = '' machine.start() machine.succeed("grep -qF 'ALLOW_REGISTRATION=true' /etc/systemd/system/librechat.service") machine.succeed("grep -qF 'SEARCH=true' /etc/systemd/system/librechat.service") machine.succeed("grep -qF 'MEILI_HOST=http://localhost:7700' /etc/systemd/system/librechat.service") machine.succeed("grep -qG 'MEILI_MASTER_KEY_FILE:/nix/store/.*meilisearch-master-key' /etc/systemd/system/librechat.service") machine.wait_for_unit("librechat.service") machine.wait_for_open_port(3080) Loading