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 pname version src;
68 hash = "sha256-ZtCTg8qNCiqlH7RsZxaWUNAoazdgmXP2GtpjDpRdvbk=";
69 };
70
71 pythonRelaxDeps = [
72 "chroma-hnswlib"
73 "orjson"
74 ];
75
76 build-system = [
77 setuptools
78 setuptools-scm
79 ];
80
81 nativeBuildInputs = [
82 cargo
83 pkg-config
84 protobuf
85 rustc
86 rustPlatform.cargoSetupHook
87 ];
88
89 buildInputs = [
90 openssl
91 zstd
92 ];
93
94 dependencies = [
95 bcrypt
96 build
97 chroma-hnswlib
98 fastapi
99 grpcio
100 httpx
101 importlib-resources
102 kubernetes
103 mmh3
104 numpy
105 onnxruntime
106 opentelemetry-api
107 opentelemetry-exporter-otlp-proto-grpc
108 opentelemetry-instrumentation-fastapi
109 opentelemetry-sdk
110 orjson
111 overrides
112 posthog
113 pulsar-client
114 pydantic
115 pypika
116 pyyaml
117 requests
118 tenacity
119 tokenizers
120 tqdm
121 typer
122 typing-extensions
123 uvicorn
124 ];
125
126 nativeCheckInputs = [
127 hypothesis
128 psutil
129 pytest-asyncio
130 pytestCheckHook
131 ];
132
133 pythonImportsCheck = [ "chromadb" ];
134
135 env = {
136 ZSTD_SYS_USE_PKG_CONFIG = true;
137 };
138
139 pytestFlagsArray = [ "-x" ];
140
141 preCheck = ''
142 (($(ulimit -n) < 1024)) && ulimit -n 1024
143 export HOME=$(mktemp -d)
144 '';
145
146 disabledTests = [
147 # Tests are laky / timing sensitive
148 "test_fastapi_server_token_authn_allows_when_it_should_allow"
149 "test_fastapi_server_token_authn_rejects_when_it_should_reject"
150 # Issue with event loop
151 "test_http_client_bw_compatibility"
152 # Issue with httpx
153 "test_not_existing_collection_delete"
154 ];
155
156 disabledTestPaths = [
157 # Tests require network access
158 "chromadb/test/auth/test_simple_rbac_authz.py"
159 "chromadb/test/db/test_system.py"
160 "chromadb/test/ef/test_default_ef.py"
161 "chromadb/test/property/"
162 "chromadb/test/property/test_cross_version_persist.py"
163 "chromadb/test/stress/"
164 "chromadb/test/test_api.py"
165 ];
166
167 __darwinAllowLocalNetworking = true;
168
169 passthru.tests = {
170 inherit (nixosTests) chromadb;
171 };
172
173 meta = with lib; {
174 description = "AI-native open-source embedding database";
175 homepage = "https://github.com/chroma-core/chroma";
176 changelog = "https://github.com/chroma-core/chroma/releases/tag/${version}";
177 license = licenses.asl20;
178 maintainers = with maintainers; [ fab ];
179 mainProgram = "chroma";
180 broken = stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64;
181 };
182}