diff options
Diffstat (limited to 'latex.nix')
-rw-r--r-- | latex.nix | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/latex.nix b/latex.nix new file mode 100644 index 0000000..7c0de49 --- /dev/null +++ b/latex.nix | |||
@@ -0,0 +1,73 @@ | |||
1 | { runCommand | ||
2 | , makeFontsConf | ||
3 | , fira | ||
4 | , fira-code | ||
5 | , freefont_ttf | ||
6 | , lmodern | ||
7 | , pandoc | ||
8 | , pandoc-lua-filters | ||
9 | , pandoc-templates | ||
10 | , pygments | ||
11 | , texlive | ||
12 | , which | ||
13 | , documentType ? "latex" | ||
14 | }: | ||
15 | |||
16 | { name, src }: | ||
17 | |||
18 | runCommand name | ||
19 | { | ||
20 | inherit src; | ||
21 | |||
22 | nativeBuildInputs = [ | ||
23 | pandoc | ||
24 | pygments | ||
25 | fira-code | ||
26 | which | ||
27 | (texlive.combine { | ||
28 | inherit (texlive) | ||
29 | scheme-medium | ||
30 | latexmk | ||
31 | |||
32 | beamertheme-metropolis | ||
33 | beamercolorthemeowl | ||
34 | |||
35 | # For framed code listings | ||
36 | tcolorbox environ | ||
37 | |||
38 | # Optional pandoc dependencies | ||
39 | microtype upquote parskip xurl bookmark footnotehyper | ||
40 | |||
41 | # Some dependencies | ||
42 | fvextra pgfopts minted catchfile xstring framed; | ||
43 | }) | ||
44 | ]; | ||
45 | |||
46 | FONTCONFIG_FILE = makeFontsConf { | ||
47 | fontDirectories = [ lmodern freefont_ttf fira fira-code ]; | ||
48 | }; | ||
49 | } '' | ||
50 | unpackFile $src | ||
51 | cd */ | ||
52 | chmod -R u+w . | ||
53 | |||
54 | pandoc ${name}.md -t ${documentType} -so document.tex \ | ||
55 | --template=${pandoc-templates}/default.latex \ | ||
56 | --lua-filter=${pandoc-lua-filters}/share/pandoc/filters/minted.lua \ | ||
57 | --pdf-engine=xelatex \ | ||
58 | --pdf-engine-opt=-aux-directory=./build \ | ||
59 | --pdf-engine-opt=-shell-escape | ||
60 | |||
61 | latexmk \ | ||
62 | -shell-escape \ | ||
63 | -xelatex \ | ||
64 | -8bit \ | ||
65 | -interaction=nonstopmode \ | ||
66 | -verbose \ | ||
67 | -file-line-error \ | ||
68 | -output-directory=./build document.tex | ||
69 | |||
70 | cp build/document.pdf $out | ||
71 | '' | ||
72 | |||
73 | # TODO: diagram-generator? | ||