1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 gitMinimal,
7 portaudio,
8 playwright-driver,
9 symlinkJoin,
10 nltk-data,
11 pythonOlder,
12 pythonAtLeast,
13 setuptools-scm,
14 aiohappyeyeballs,
15 aiohttp,
16 aiosignal,
17 annotated-types,
18 anyio,
19 attrs,
20 backoff,
21 beautifulsoup4,
22 cachetools,
23 certifi,
24 cffi,
25 charset-normalizer,
26 click,
27 configargparse,
28 diff-match-patch,
29 diskcache,
30 distro,
31 filelock,
32 flake8,
33 frozenlist,
34 fsspec,
35 gitdb,
36 gitpython,
37 google-ai-generativelanguage,
38 google-generativeai,
39 grep-ast,
40 h11,
41 hf-xet,
42 httpcore,
43 httpx,
44 huggingface-hub,
45 idna,
46 importlib-resources,
47 jinja2,
48 jiter,
49 json5,
50 jsonschema,
51 jsonschema-specifications,
52 litellm,
53 markdown-it-py,
54 markupsafe,
55 mccabe,
56 mdurl,
57 multidict,
58 networkx,
59 numpy,
60 openai,
61 oslex,
62 packaging,
63 pathspec,
64 pexpect,
65 pillow,
66 prompt-toolkit,
67 psutil,
68 ptyprocess,
69 pycodestyle,
70 pycparser,
71 pydantic,
72 pydantic-core,
73 pydub,
74 pyflakes,
75 pygments,
76 pypandoc,
77 pyperclip,
78 python-dotenv,
79 pyyaml,
80 referencing,
81 regex,
82 requests,
83 rich,
84 rpds-py,
85 scipy,
86 shtab,
87 smmap,
88 sniffio,
89 sounddevice,
90 socksio,
91 soundfile,
92 soupsieve,
93 tiktoken,
94 tokenizers,
95 tqdm,
96 tree-sitter,
97 tree-sitter-language-pack,
98 typing-extensions,
99 typing-inspection,
100 urllib3,
101 watchfiles,
102 wcwidth,
103 yarl,
104 zipp,
105 pip,
106 mixpanel,
107 monotonic,
108 posthog,
109 propcache,
110 python-dateutil,
111 pytestCheckHook,
112 greenlet,
113 playwright,
114 pyee,
115 streamlit,
116 llama-index-core,
117 llama-index-embeddings-huggingface,
118 torch,
119 nltk,
120 boto3,
121 nix-update-script,
122}:
123
124let
125 aider-nltk-data = symlinkJoin {
126 name = "aider-nltk-data";
127 paths = [
128 nltk-data.punkt_tab
129 nltk-data.stopwords
130 ];
131 };
132
133 version = "0.83.1";
134 aider-chat = buildPythonPackage {
135 pname = "aider-chat";
136 inherit version;
137 pyproject = true;
138
139 # dont support python 3.13 (Aider-AI/aider#3037)
140 disabled = pythonOlder "3.10" || pythonAtLeast "3.13";
141
142 src = fetchFromGitHub {
143 owner = "Aider-AI";
144 repo = "aider";
145 tag = "v${version}";
146 hash = "sha256-2OHPqsS1znl7G4Z8mu8oKHNPdDr4YmSfGzXLylTgooE=";
147 };
148
149 pythonRelaxDeps = true;
150
151 build-system = [ setuptools-scm ];
152
153 dependencies = [
154 aiohappyeyeballs
155 aiohttp
156 aiosignal
157 annotated-types
158 anyio
159 attrs
160 backoff
161 beautifulsoup4
162 cachetools
163 certifi
164 cffi
165 charset-normalizer
166 click
167 configargparse
168 diff-match-patch
169 diskcache
170 distro
171 filelock
172 flake8
173 frozenlist
174 fsspec
175 gitdb
176 gitpython
177 google-ai-generativelanguage
178 google-generativeai
179 grep-ast
180 h11
181 hf-xet
182 httpcore
183 httpx
184 huggingface-hub
185 idna
186 importlib-resources
187 jinja2
188 jiter
189 json5
190 jsonschema
191 jsonschema-specifications
192 litellm
193 markdown-it-py
194 markupsafe
195 mccabe
196 mdurl
197 multidict
198 networkx
199 numpy
200 openai
201 oslex
202 packaging
203 pathspec
204 pexpect
205 pillow
206 prompt-toolkit
207 psutil
208 ptyprocess
209 pycodestyle
210 pycparser
211 pydantic
212 pydantic-core
213 pydub
214 pyflakes
215 pygments
216 pypandoc
217 pyperclip
218 python-dotenv
219 pyyaml
220 referencing
221 regex
222 requests
223 rich
224 rpds-py
225 scipy
226 shtab
227 smmap
228 sniffio
229 sounddevice
230 socksio
231 soundfile
232 soupsieve
233 tiktoken
234 tokenizers
235 tqdm
236 tree-sitter
237 tree-sitter-language-pack
238 typing-extensions
239 typing-inspection
240 urllib3
241 watchfiles
242 wcwidth
243 yarl
244 zipp
245 pip
246
247 # Not listed in requirements
248 mixpanel
249 monotonic
250 posthog
251 propcache
252 python-dateutil
253 ];
254
255 buildInputs = [ portaudio ];
256
257 nativeCheckInputs = [
258 pytestCheckHook
259 gitMinimal
260 ];
261
262 postPatch = ''
263 substituteInPlace aider/linter.py --replace-fail "\"flake8\"" "\"${flake8}\""
264 '';
265
266 disabledTestPaths = [
267 # Tests require network access
268 "tests/scrape/test_scrape.py"
269 # Expected 'mock' to have been called once
270 "tests/help/test_help.py"
271 ];
272
273 disabledTests =
274 [
275 # Tests require network
276 "test_urls"
277 "test_get_commit_message_with_custom_prompt"
278 # FileNotFoundError
279 "test_get_commit_message"
280 # Expected 'launch_gui' to have been called once
281 "test_browser_flag_imports_streamlit"
282 # AttributeError
283 "test_simple_send_with_retries"
284 # Expected 'check_version' to have been called once
285 "test_main_exit_calls_version_check"
286 # AssertionError: assert 2 == 1
287 "test_simple_send_non_retryable_error"
288 # Broken tests (Aider-AI/aider#3679)
289 "test_language_ocaml"
290 "test_language_ocaml_interface"
291 ]
292 ++ lib.optionals stdenv.hostPlatform.isDarwin [
293 # Tests fails on darwin
294 "test_dark_mode_sets_code_theme"
295 "test_default_env_file_sets_automatic_variable"
296 # FileNotFoundError: [Errno 2] No such file or directory: 'vim'
297 "test_pipe_editor"
298 ];
299
300 makeWrapperArgs = [
301 "--set"
302 "AIDER_CHECK_UPDATE"
303 "false"
304 "--set"
305 "AIDER_ANALYTICS"
306 "false"
307 ];
308
309 preCheck = ''
310 export HOME=$(mktemp -d)
311 export AIDER_ANALYTICS="false"
312 '';
313
314 optional-dependencies = {
315 playwright = [
316 greenlet
317 playwright
318 pyee
319 typing-extensions
320 ];
321 browser = [
322 streamlit
323 ];
324 help = [
325 llama-index-core
326 llama-index-embeddings-huggingface
327 torch
328 nltk
329 ];
330 bedrock = [
331 boto3
332 ];
333 };
334
335 passthru = {
336 withOptional =
337 {
338 withPlaywright ? false,
339 withBrowser ? false,
340 withHelp ? false,
341 withBedrock ? false,
342 withAll ? false,
343 ...
344 }:
345 aider-chat.overridePythonAttrs (
346 {
347 dependencies,
348 makeWrapperArgs,
349 propagatedBuildInputs ? [ ],
350 ...
351 }:
352
353 {
354 dependencies =
355 dependencies
356 ++ lib.optionals (withAll || withPlaywright) aider-chat.optional-dependencies.playwright
357 ++ lib.optionals (withAll || withBrowser) aider-chat.optional-dependencies.browser
358 ++ lib.optionals (withAll || withHelp) aider-chat.optional-dependencies.help
359 ++ lib.optionals (withAll || withBedrock) aider-chat.optional-dependencies.bedrock;
360
361 propagatedBuildInputs =
362 propagatedBuildInputs
363 ++ lib.optionals (withAll || withPlaywright) [ playwright-driver.browsers ];
364
365 makeWrapperArgs =
366 makeWrapperArgs
367 ++ lib.optionals (withAll || withPlaywright) [
368 "--set"
369 "PLAYWRIGHT_BROWSERS_PATH"
370 "${playwright-driver.browsers}"
371 "--set"
372 "PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS"
373 "true"
374 ]
375 ++ lib.optionals (withAll || withHelp) [
376 "--set"
377 "NLTK_DATA"
378 "${aider-nltk-data}"
379 ];
380 }
381 );
382
383 updateScript = nix-update-script {
384 extraArgs = [
385 "--version-regex"
386 "^v([0-9.]+)$"
387 ];
388 };
389 };
390
391 meta = {
392 description = "AI pair programming in your terminal";
393 homepage = "https://github.com/paul-gauthier/aider";
394 changelog = "https://github.com/paul-gauthier/aider/blob/v${version}/HISTORY.md";
395 license = lib.licenses.asl20;
396 maintainers = with lib.maintainers; [
397 happysalada
398 yzx9
399 ];
400 mainProgram = "aider";
401 };
402 };
403in
404aider-chat