1{
2 lib,
3 stdenv,
4 bcrypt,
5 build,
6 buildPythonPackage,
7 cargo,
8 chroma-hnswlib,
9 fastapi,
10 fetchFromGitHub,
11 grpcio,
12 httpx,
13 hypothesis,
14 importlib-resources,
15 kubernetes,
16 mmh3,
17 nixosTests,
18 numpy,
19 onnxruntime,
20 openssl,
21 opentelemetry-api,
22 opentelemetry-exporter-otlp-proto-grpc,
23 opentelemetry-instrumentation-fastapi,
24 opentelemetry-sdk,
25 orjson,
26 overrides,
27 pkg-config,
28 posthog,
29 protobuf,
30 psutil,
31 pulsar-client,
32 pydantic,
33 pypika,
34 pytest-asyncio,
35 pytestCheckHook,
36 pythonOlder,
37 pyyaml,
38 requests,
39 rustc,
40 rustPlatform,
41 setuptools-scm,
42 setuptools,
43 tenacity,
44 tokenizers,
45 tqdm,
46 typer,
47 typing-extensions,
48 uvicorn,
49 zstd,
50}:
51
52buildPythonPackage rec {
53 pname = "chromadb";
54 version = "0.5.20";
55 pyproject = true;
56
57 disabled = pythonOlder "3.9";
58
59 src = fetchFromGitHub {
60 owner = "chroma-core";
61 repo = "chroma";
62 tag = version;
63 hash = "sha256-DQHkgCHtrn9xi7Kp7TZ5NP1EtFtTH5QOvne9PUvxsWc=";
64 };
65
66 cargoDeps = rustPlatform.fetchCargoVendor {
67 inherit src;
68 name = "${pname}-${version}";
69 hash = "sha256-ZtCTg8qNCiqlH7RsZxaWUNAoazdgmXP2GtpjDpRdvbk=";
70 };
71
72 pythonRelaxDeps = [
73 "chroma-hnswlib"
74 "orjson"
75 ];
76
77 build-system = [
78 setuptools
79 setuptools-scm
80 ];
81
82 nativeBuildInputs = [
83 cargo
84 pkg-config
85 protobuf
86 rustc
87 rustPlatform.cargoSetupHook
88 ];
89
90 buildInputs = [
91 openssl
92 zstd
93 ];
94
95 dependencies = [
96 bcrypt
97 build
98 chroma-hnswlib
99 fastapi
100 grpcio
101 httpx
102 importlib-resources
103 kubernetes
104 mmh3
105 numpy
106 onnxruntime
107 opentelemetry-api
108 opentelemetry-exporter-otlp-proto-grpc
109 opentelemetry-instrumentation-fastapi
110 opentelemetry-sdk
111 orjson
112 overrides
113 posthog
114 pulsar-client
115 pydantic
116 pypika
117 pyyaml
118 requests
119 tenacity
120 tokenizers
121 tqdm
122 typer
123 typing-extensions
124 uvicorn
125 ];
126
127 nativeCheckInputs = [
128 hypothesis
129 psutil
130 pytest-asyncio
131 pytestCheckHook
132 ];
133
134 pythonImportsCheck = [ "chromadb" ];
135
136 env = {
137 ZSTD_SYS_USE_PKG_CONFIG = true;
138 };
139
140 pytestFlagsArray = [ "-x" ];
141
142 preCheck = ''
143 (($(ulimit -n) < 1024)) && ulimit -n 1024
144 export HOME=$(mktemp -d)
145 '';
146
147 disabledTests = [
148 # Tests are laky / timing sensitive
149 "test_fastapi_server_token_authn_allows_when_it_should_allow"
150 "test_fastapi_server_token_authn_rejects_when_it_should_reject"
151 # Issue with event loop
152 "test_http_client_bw_compatibility"
153 # Issue with httpx
154 "test_not_existing_collection_delete"
155 ];
156
157 disabledTestPaths = [
158 # Tests require network access
159 "chromadb/test/auth/test_simple_rbac_authz.py"
160 "chromadb/test/db/test_system.py"
161 "chromadb/test/ef/test_default_ef.py"
162 "chromadb/test/property/"
163 "chromadb/test/property/test_cross_version_persist.py"
164 "chromadb/test/stress/"
165 "chromadb/test/test_api.py"
166 ];
167
168 __darwinAllowLocalNetworking = true;
169
170 passthru.tests = {
171 inherit (nixosTests) chromadb;
172 };
173
174 meta = with lib; {
175 description = "AI-native open-source embedding database";
176 homepage = "https://github.com/chroma-core/chroma";
177 changelog = "https://github.com/chroma-core/chroma/releases/tag/${version}";
178 license = licenses.asl20;
179 maintainers = with maintainers; [ fab ];
180 mainProgram = "chroma";
181 broken = stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64;
182 };
183}