summaryrefslogtreecommitdiffstats
path: root/latex.nix
diff options
context:
space:
mode:
Diffstat (limited to 'latex.nix')
-rw-r--r--latex.nix43
1 files changed, 27 insertions, 16 deletions
diff --git a/latex.nix b/latex.nix
index 7c0de49..17b348d 100644
--- a/latex.nix
+++ b/latex.nix
@@ -1,4 +1,5 @@
1{ runCommand 1{ lib
2, runCommand
2, makeFontsConf 3, makeFontsConf
3, fira 4, fira
4, fira-code 5, fira-code
@@ -13,7 +14,9 @@
13, documentType ? "latex" 14, documentType ? "latex"
14}: 15}:
15 16
16{ name, src }: 17{ name, src, extraPandocArgs ? [ ], extraLatexArgs ? [ ] }:
18
19with lib;
17 20
18runCommand name 21runCommand name
19{ 22{
@@ -46,26 +49,34 @@ runCommand name
46 FONTCONFIG_FILE = makeFontsConf { 49 FONTCONFIG_FILE = makeFontsConf {
47 fontDirectories = [ lmodern freefont_ttf fira fira-code ]; 50 fontDirectories = [ lmodern freefont_ttf fira fira-code ];
48 }; 51 };
52
53 pandocCmd = ''
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 ${escapeShellArgs extraPandocArgs}
60 '';
61
62 latexmkCmd = ''
63 latexmk
64 -shell-escape
65 -xelatex
66 -8bit
67 -interaction=nonstopmode
68 -verbose
69 -file-line-error
70 -output-directory=./build document.tex ${escapeShellArgs extraLatexArgs}
71 '';
49} '' 72} ''
50 unpackFile $src 73 unpackFile $src
51 cd */ 74 cd */
52 chmod -R u+w . 75 chmod -R u+w .
53 76
54 pandoc ${name}.md -t ${documentType} -so document.tex \ 77 $pandocCmd
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 78
61 latexmk \ 79 $latexmkCmd
62 -shell-escape \
63 -xelatex \
64 -8bit \
65 -interaction=nonstopmode \
66 -verbose \
67 -file-line-error \
68 -output-directory=./build document.tex
69 80
70 cp build/document.pdf $out 81 cp build/document.pdf $out
71'' 82''