1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 texliveInfraOnly,
6
7 # build-system
8 poetry-core,
9 setuptools,
10
11 # buildInputs
12 cairo,
13
14 # dependencies
15 av,
16 beautifulsoup4,
17 click,
18 cloup,
19 decorator,
20 isosurfaces,
21 manimpango,
22 mapbox-earcut,
23 moderngl,
24 moderngl-window,
25 networkx,
26 numpy,
27 pillow,
28 pycairo,
29 pydub,
30 pygments,
31 rich,
32 scipy,
33 screeninfo,
34 skia-pathops,
35 srt,
36 svgelements,
37 tqdm,
38 typing-extensions,
39 watchdog,
40
41 # optional-dependencies
42 jupyterlab,
43 notebook,
44
45 # tests
46 ffmpeg,
47 pytest-cov-stub,
48 pytest-xdist,
49 pytestCheckHook,
50 versionCheckHook,
51}:
52
53let
54 # According to ManimCommunity documentation manim uses tex-packages packaged
55 # in a custom distribution called "manim-latex",
56 #
57 # https://community.chocolatey.org/packages/manim-latex#files
58 #
59 # which includes another custom distribution called tinytex, for which the
60 # package list can be found at
61 #
62 # https://github.com/yihui/tinytex/blob/master/tools/pkgs-custom.txt
63 #
64 # these two combined add up to:
65 manim-tinytex = texliveInfraOnly.withPackages (
66 ps: with ps; [
67
68 # tinytex
69 amsfonts
70 amsmath
71 atbegshi
72 atveryend
73 auxhook
74 babel
75 bibtex
76 bigintcalc
77 bitset
78 booktabs
79 cm
80 dehyph
81 dvipdfmx
82 dvips
83 ec
84 epstopdf-pkg
85 etex
86 etexcmds
87 etoolbox
88 euenc
89 everyshi
90 fancyvrb
91 filehook
92 firstaid
93 float
94 fontspec
95 framed
96 geometry
97 gettitlestring
98 glyphlist
99 graphics
100 graphics-cfg
101 graphics-def
102 grffile
103 helvetic
104 hycolor
105 hyperref
106 hyph-utf8
107 iftex
108 inconsolata
109 infwarerr
110 intcalc
111 knuth-lib
112 kvdefinekeys
113 kvoptions
114 kvsetkeys
115 l3backend
116 l3kernel
117 l3packages
118 latex
119 latex-amsmath-dev
120 latex-bin
121 latex-fonts
122 latex-tools-dev
123 latexconfig
124 latexmk
125 letltxmacro
126 lm
127 lm-math
128 ltxcmds
129 lua-alt-getopt
130 luahbtex
131 lualatex-math
132 lualibs
133 luaotfload
134 luatex
135 mdwtools
136 metafont
137 mfware
138 natbib
139 pdfescape
140 pdftex
141 pdftexcmds
142 plain
143 psnfss
144 refcount
145 rerunfilecheck
146 stringenc
147 tex
148 tex-ini-files
149 times
150 tipa
151 tools
152 unicode-data
153 unicode-math
154 uniquecounter
155 url
156 xcolor
157 xetex
158 xetexconfig
159 xkeyval
160 xunicode
161 zapfding
162
163 # manim-latex
164 standalone
165 everysel
166 preview
167 doublestroke
168 setspace
169 rsfs
170 relsize
171 ragged2e
172 fundus-calligra
173 microtype
174 wasysym
175 physics
176 dvisvgm
177 jknapltx
178 wasy
179 cm-super
180 babel-english
181 gnu-freefont
182 mathastext
183 cbfonts-fd
184 ]
185 );
186 # https://github.com/ManimCommunity/manim/pull/4037
187 av_13_1 = av.overridePythonAttrs (rec {
188 version = "13.1.0";
189 src = fetchFromGitHub {
190 owner = "PyAV-Org";
191 repo = "PyAV";
192 tag = "v${version}";
193 hash = "sha256-x2a9SC4uRplC6p0cD7fZcepFpRidbr6JJEEOaGSWl60=";
194 };
195 });
196in
197buildPythonPackage rec {
198 pname = "manim";
199 pyproject = true;
200 version = "0.19.0";
201
202 src = fetchFromGitHub {
203 owner = "ManimCommunity";
204 repo = "manim";
205 tag = "v${version}";
206 hash = "sha256-eQgp/GwKsfQA1ZgqfB3HF2ThEgH3Fbn9uAtcko9pkjs=";
207 };
208
209 build-system = [
210 poetry-core
211 setuptools
212 ];
213
214 patches = [ ./pytest-report-header.patch ];
215
216 buildInputs = [ cairo ];
217
218 dependencies = [
219 av_13_1
220 beautifulsoup4
221 click
222 cloup
223 decorator
224 isosurfaces
225 manimpango
226 mapbox-earcut
227 moderngl
228 moderngl-window
229 networkx
230 numpy
231 pillow
232 pycairo
233 pydub
234 pygments
235 rich
236 scipy
237 screeninfo
238 skia-pathops
239 srt
240 svgelements
241 tqdm
242 typing-extensions
243 watchdog
244 ];
245
246 optional-dependencies = {
247 jupyterlab = [
248 jupyterlab
249 notebook
250 ];
251 # TODO package dearpygui
252 # gui = [ dearpygui ];
253 };
254
255 makeWrapperArgs = [
256 "--prefix"
257 "PATH"
258 ":"
259 (lib.makeBinPath [
260 ffmpeg
261 manim-tinytex
262 ])
263 ];
264
265 nativeCheckInputs = [
266 ffmpeg
267 manim-tinytex
268 pytest-cov-stub
269 pytest-xdist
270 pytestCheckHook
271 versionCheckHook
272 ];
273 versionCheckProgramArg = "--version";
274
275 # about 55 of ~600 tests failing mostly due to demand for display
276 disabledTests = import ./failing_tests.nix;
277
278 pythonImportsCheck = [ "manim" ];
279
280 meta = {
281 description = "Animation engine for explanatory math videos - Community version";
282 longDescription = ''
283 Manim is an animation engine for explanatory math videos. It's used to
284 create precise animations programmatically, as seen in the videos of
285 3Blue1Brown on YouTube. This is the community maintained version of
286 manim.
287 '';
288 mainProgram = "manim";
289 changelog = "https://docs.manim.community/en/latest/changelog/${version}-changelog.html";
290 homepage = "https://github.com/ManimCommunity/manim";
291 license = lib.licenses.mit;
292 maintainers = with lib.maintainers; [ osbm ];
293 };
294}