This repository has been archived by the owner on Jun 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdefault.nix
107 lines (88 loc) · 2.18 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
with import (fetchTarball {
url = "https://github.com/nixos/nixpkgs-channels/archive/5d3fd36.tar.gz";
sha256 = "1yjn56jsczih4chjcll63a20v3nwv1jhl2rf6rk8d8cwvb10g0mk";
}) {};
let
latexPackage = texlive.combine {
inherit (texlive)
scheme-small
# Build packages
latexmk
# Basic document
koma-script
lipsum
babel
enumitem
bigfoot
slantsc
xpatch
minted
fvextra
ifplatform
framed
appendix
# Bibliography
biber
biblatex
biblatex-apa
csquotes
logreq
xstring
# Glossary/Abbreviations
tracklang
substr
datatool
xfor
mfirstuc
glossaries
glossaries-extra
glossaries-english
;
};
pplatex =
stdenv.mkDerivation rec {
name = "pplatex-${version}";
version = "1.0-rc2";
src = fetchFromGitHub {
owner = "stefanhepp";
repo = "pplatex";
rev = name;
sha256 = "0xw7nvi2l15iyp9sm8vmmqghi54v99bcivqvx89f5v2gw0kw47k3";
};
buildInputs = [ cmake pkgconfig pcre ];
installPhase = ''
mkdir -p $out/bin
cp src/pplatex $out/bin/pplatex
'';
};
mainFile = "main.tex";
in
stdenv.mkDerivation rec {
pname = "stgtinf16a-nosql-book";
version = "0.0.1";
src = ./.;
buildInputs = [
latexPackage pplatex
python3Packages.pygments
which
];
preBuild = ''
# We could be building from an unclean directory, so remove intermediate files first
latexmk -C
rm -f "$(basename ${mainFile} .tex).bbl" "$(basename ${mainFile} .tex).run.xml"
'';
buildPhase = ''
latexmk -pdflatex="pplatex -c pdflatex --" --shell-escape -pdf -interaction=nonstopmode "${mainFile}" 2>&1 | tee latexmk_log.txt
'';
installPhase = ''
mv "./$(basename ${mainFile} .tex).pdf" $out
'';
doCheck = true;
checkPhase = ''
function build_error() {
echo "=====> There have been warnings or errors in the last run, fix them!"
exit 1
}
cat latexmk_log.txt | grep "o) Errors:" | tail -1 | grep "o) Errors: 0, Warnings: 0" || build_error
'';
}