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