diff options
-rw-r--r-- | latex.nix | 131 |
1 files changed, 69 insertions, 62 deletions
@@ -1,72 +1,79 @@ | |||
1 | { lib | 1 | { |
2 | , runCommand | 2 | lib, |
3 | , makeFontsConf | 3 | runCommand, |
4 | , fira | 4 | makeFontsConf, |
5 | , fira-code | 5 | fira, |
6 | , league-of-moveable-type | 6 | fira-code, |
7 | , inkscape | 7 | fira-mono, |
8 | , freefont_ttf | 8 | league-of-moveable-type, |
9 | , lmodern | 9 | inkscape, |
10 | , pandoc | 10 | freefont_ttf, |
11 | , pandoc-lua-filters | 11 | lmodern, |
12 | , pandoc-templates | 12 | pandoc, |
13 | , pygments | 13 | pandoc-lua-filters, |
14 | , texlive | 14 | pandoc-templates, |
15 | , which | 15 | pygments, |
16 | , documentType ? "latex" | 16 | texlive, |
17 | which, | ||
18 | documentType ? "latex", | ||
19 | }: { | ||
20 | name, | ||
21 | src, | ||
22 | extraPandocArgs ? "", | ||
23 | extraLatexArgs ? "", | ||
24 | extraTeXLivePackages ? {}, | ||
17 | }: | 25 | }: |
18 | |||
19 | { name, src, extraPandocArgs ? "", extraLatexArgs ? "" }: | ||
20 | |||
21 | with lib; | 26 | with lib; |
27 | runCommand name | ||
28 | { | ||
29 | inherit src; | ||
22 | 30 | ||
23 | runCommand name | 31 | nativeBuildInputs = [ |
24 | { | 32 | pandoc |
25 | inherit src; | 33 | pygments |
34 | fira-code | ||
35 | fira-mono | ||
36 | which | ||
37 | (texlive.combine ({ | ||
38 | inherit (texlive) scheme-full; | ||
39 | } // extraTeXLivePackages)) | ||
40 | league-of-moveable-type | ||
41 | inkscape | ||
42 | ]; | ||
26 | 43 | ||
27 | nativeBuildInputs = [ | 44 | FONTCONFIG_FILE = makeFontsConf { |
28 | pandoc | 45 | fontDirectories = [lmodern freefont_ttf fira fira-code]; |
29 | pygments | 46 | }; |
30 | fira-code | ||
31 | which | ||
32 | texlive.combined.scheme-full | ||
33 | league-of-moveable-type | ||
34 | inkscape | ||
35 | ]; | ||
36 | 47 | ||
37 | FONTCONFIG_FILE = makeFontsConf { | 48 | pandocCmd = '' |
38 | fontDirectories = [ lmodern freefont_ttf fira fira-code ]; | 49 | pandoc ${name}.md -t ${documentType} -so document.tex |
39 | }; | 50 | --template=${pandoc-templates}/default.latex |
51 | --lua-filter=${pandoc-lua-filters}/share/pandoc/filters/minted.lua | ||
52 | --pdf-engine=xelatex | ||
53 | --pdf-engine-opt=-aux-directory=./build | ||
54 | --pdf-engine-opt=-shell-escape ${extraPandocArgs} | ||
55 | ''; | ||
40 | 56 | ||
41 | pandocCmd = '' | 57 | latexmkCmd = '' |
42 | pandoc ${name}.md -t ${documentType} -so document.tex | 58 | latexmk |
43 | --template=${pandoc-templates}/default.latex | 59 | -shell-escape |
44 | --lua-filter=${pandoc-lua-filters}/share/pandoc/filters/minted.lua | 60 | -xelatex |
45 | --pdf-engine=xelatex | 61 | -8bit |
46 | --pdf-engine-opt=-aux-directory=./build | 62 | -interaction=nonstopmode |
47 | --pdf-engine-opt=-shell-escape ${extraPandocArgs} | 63 | -verbose |
48 | ''; | 64 | -file-line-error |
65 | -output-directory=./build document.tex ${extraLatexArgs} | ||
66 | ''; | ||
67 | } '' | ||
68 | unpackFile $src | ||
69 | cd */ | ||
70 | chmod -R u+w . | ||
49 | 71 | ||
50 | latexmkCmd = '' | 72 | $pandocCmd |
51 | latexmk | ||
52 | -shell-escape | ||
53 | -xelatex | ||
54 | -8bit | ||
55 | -interaction=nonstopmode | ||
56 | -verbose | ||
57 | -file-line-error | ||
58 | -output-directory=./build document.tex ${extraLatexArgs} | ||
59 | ''; | ||
60 | } '' | ||
61 | unpackFile $src | ||
62 | cd */ | ||
63 | chmod -R u+w . | ||
64 | 73 | ||
65 | $pandocCmd | 74 | $latexmkCmd |
66 | |||
67 | $latexmkCmd | ||
68 | |||
69 | cp build/document.pdf $out | ||
70 | '' | ||
71 | 75 | ||
76 | cp build/document.pdf $out | ||
77 | '' | ||
72 | # TODO: diagram-generator? | 78 | # TODO: diagram-generator? |
79 | |||