From 0b3000e5eae26ad1a2458cc1ae230d98148e0248 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Wed, 9 Mar 2022 10:42:04 +0100 Subject: latex: factor pandoc and latex cmds in env var for devshell --- latex.nix | 43 +++++++++++++++++++++++++++---------------- 1 file 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 @@ -{ runCommand +{ lib +, runCommand , makeFontsConf , fira , fira-code @@ -13,7 +14,9 @@ , documentType ? "latex" }: -{ name, src }: +{ name, src, extraPandocArgs ? [ ], extraLatexArgs ? [ ] }: + +with lib; runCommand name { @@ -46,26 +49,34 @@ runCommand name FONTCONFIG_FILE = makeFontsConf { fontDirectories = [ lmodern freefont_ttf fira fira-code ]; }; + + pandocCmd = '' + pandoc ${name}.md -t ${documentType} -so document.tex + --template=${pandoc-templates}/default.latex + --lua-filter=${pandoc-lua-filters}/share/pandoc/filters/minted.lua + --pdf-engine=xelatex + --pdf-engine-opt=-aux-directory=./build + --pdf-engine-opt=-shell-escape ${escapeShellArgs extraPandocArgs} + ''; + + latexmkCmd = '' + latexmk + -shell-escape + -xelatex + -8bit + -interaction=nonstopmode + -verbose + -file-line-error + -output-directory=./build document.tex ${escapeShellArgs extraLatexArgs} + ''; } '' unpackFile $src cd */ chmod -R u+w . - pandoc ${name}.md -t ${documentType} -so document.tex \ - --template=${pandoc-templates}/default.latex \ - --lua-filter=${pandoc-lua-filters}/share/pandoc/filters/minted.lua \ - --pdf-engine=xelatex \ - --pdf-engine-opt=-aux-directory=./build \ - --pdf-engine-opt=-shell-escape + $pandocCmd - latexmk \ - -shell-escape \ - -xelatex \ - -8bit \ - -interaction=nonstopmode \ - -verbose \ - -file-line-error \ - -output-directory=./build document.tex + $latexmkCmd cp build/document.pdf $out '' -- cgit v1.2.3