mirror of
https://github.com/juspay/services-flake.git
synced 2024-09-17 15:28:33 +03:00
parent
cf7685089b
commit
2fba2e0009
@ -21,5 +21,6 @@ short-title: Services
|
||||
- [[tempo]]
|
||||
- [[prometheus]]#
|
||||
- [[cassandra]]#
|
||||
- [[weaviate]]#
|
||||
|
||||
[gh]: https://github.com/juspay/services-flake/issues/132
|
||||
|
67
doc/weaviate.md
Normal file
67
doc/weaviate.md
Normal file
@ -0,0 +1,67 @@
|
||||
# Weaviate
|
||||
|
||||
[Weaviate] is an open-source vector database that stores both objects and vectors, allowing for the combination of vector search with structured filtering with the fault tolerance and scalability of a cloud-native database.
|
||||
|
||||
[Weaviate]: https://github.com/weaviate/weaviate
|
||||
|
||||
{#start}
|
||||
|
||||
## Getting started
|
||||
|
||||
```nix
|
||||
# In `perSystem.process-compose.<name>`
|
||||
{
|
||||
services.weaviate."weaviate1".enable = true;
|
||||
}
|
||||
```
|
||||
|
||||
{#tips}
|
||||
|
||||
## Tips & Tricks
|
||||
|
||||
{#envs}
|
||||
|
||||
### Environment variables
|
||||
|
||||
To see list of environment variables, see [this link](https://weaviate.io/developers/weaviate/config-refs/env-vars).
|
||||
|
||||
```nix
|
||||
{
|
||||
services.weaviate."weaviate1" = {
|
||||
enable = true;
|
||||
envs = {
|
||||
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED = true;
|
||||
QUERY_DEFAULTS_LIMIT = 100;
|
||||
DISABLE_TELEMETRY = true;
|
||||
LIMIT_RESOURCES = true;
|
||||
ENABLE_MODULES = ["text2vec-openai" "generative-openai"];
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
{#port}
|
||||
|
||||
### Use a different port
|
||||
|
||||
```nix
|
||||
{
|
||||
services.weaviate."weaviate1" = {
|
||||
enable = true;
|
||||
port = 8080;
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
{#dataDir}
|
||||
|
||||
### Use a different data path
|
||||
|
||||
```nix
|
||||
{
|
||||
services.weaviate."weaviate1" = {
|
||||
enable = true;
|
||||
dataDir = "./data";
|
||||
};
|
||||
}
|
||||
```
|
@ -18,5 +18,6 @@ in
|
||||
./pgadmin.nix
|
||||
./cassandra.nix
|
||||
./tempo.nix
|
||||
./weaviate.nix
|
||||
];
|
||||
}
|
||||
|
99
nix/weaviate.nix
Normal file
99
nix/weaviate.nix
Normal file
@ -0,0 +1,99 @@
|
||||
{ pkgs, lib, name, config, ... }:
|
||||
let
|
||||
inherit (lib) types;
|
||||
asAtom = value:
|
||||
if builtins.isList value then lib.concatStringsSep "," value else value;
|
||||
toStr = value:
|
||||
if builtins.isString value then value else builtins.toJSON value;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
enable = lib.mkEnableOption name;
|
||||
|
||||
package = lib.mkPackageOption pkgs "weaviate" { };
|
||||
|
||||
dataDir = lib.mkOption {
|
||||
type = types.str;
|
||||
default = "./data/${name}";
|
||||
description = "Path to the Weaviate data store";
|
||||
};
|
||||
|
||||
host = lib.mkOption {
|
||||
type = types.str;
|
||||
default = "127.0.0.1";
|
||||
description = ''
|
||||
The IP to listen on
|
||||
'';
|
||||
example = "0.0.0.0";
|
||||
};
|
||||
|
||||
port = lib.mkOption {
|
||||
type = types.port;
|
||||
default = 8080;
|
||||
description = ''
|
||||
The port to listen on for connections
|
||||
'';
|
||||
};
|
||||
|
||||
environment = lib.mkOption {
|
||||
type = types.attrsOf (types.oneOf [ types.raw (types.listOf types.str) ]);
|
||||
default = { };
|
||||
description = ''
|
||||
Weaviate environment variables.
|
||||
|
||||
See https://weaviate.io/developers/weaviate/config-refs/env-vars
|
||||
'';
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED = true;
|
||||
QUERY_DEFAULTS_LIMIT = 100;
|
||||
DISABLE_TELEMETRY = true;
|
||||
LIMIT_RESOURCES = true;
|
||||
ENABLE_MODULES = ["text2vec-openai" "generative-openai"];
|
||||
}
|
||||
'';
|
||||
apply = lib.mapAttrs (_: value: toStr (asAtom value));
|
||||
};
|
||||
|
||||
outputs.settings = lib.mkOption {
|
||||
type = types.deferredModule;
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
default = {
|
||||
processes = {
|
||||
"${name}" =
|
||||
let
|
||||
startScript = pkgs.writeShellApplication {
|
||||
name = "start-weaviate";
|
||||
runtimeInputs = [ config.package ];
|
||||
text = ''
|
||||
exec weaviate --scheme http --host ${config.host} --port ${toString config.port}
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
environment = config.environment // { "PERSISTENCE_DATA_PATH" = config.dataDir; };
|
||||
|
||||
command = startScript;
|
||||
|
||||
readiness_probe = {
|
||||
http_get = {
|
||||
inherit (config) host port;
|
||||
path = "/v1/.well-known/ready";
|
||||
};
|
||||
initial_delay_seconds = 3;
|
||||
period_seconds = 10;
|
||||
timeout_seconds = 4;
|
||||
success_threshold = 1;
|
||||
failure_threshold = 5;
|
||||
};
|
||||
namespace = name;
|
||||
|
||||
# https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy
|
||||
availability.restart = "on_failure";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
24
nix/weaviate_test.nix
Normal file
24
nix/weaviate_test.nix
Normal file
@ -0,0 +1,24 @@
|
||||
{ pkgs, config, ... }: {
|
||||
services.weaviate."weaviate1" = {
|
||||
enable = true;
|
||||
environment = {
|
||||
# To fix the problem with nix failing to run weaviate in sandbox mode
|
||||
CLUSTER_ADVERTISE_ADDR = "127.0.0.1";
|
||||
};
|
||||
};
|
||||
|
||||
settings.processes.test =
|
||||
let
|
||||
cfg = config.services.weaviate."weaviate1";
|
||||
in
|
||||
{
|
||||
command = pkgs.writeShellApplication {
|
||||
runtimeInputs = [ cfg.package pkgs.curl ];
|
||||
text = ''
|
||||
curl http://localhost:8080/v1/.well-known/live
|
||||
'';
|
||||
name = "weaviate-test";
|
||||
};
|
||||
depends_on."weaviate1".condition = "process_healthy";
|
||||
};
|
||||
}
|
@ -47,6 +47,7 @@
|
||||
"${inputs.services-flake}/nix/pgadmin_test.nix"
|
||||
"${inputs.services-flake}/nix/cassandra_test.nix"
|
||||
"${inputs.services-flake}/nix/tempo_test.nix"
|
||||
"${inputs.services-flake}/nix/weaviate_test.nix"
|
||||
]);
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user