-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
57 lines (56 loc) · 2.46 KB
/
flake.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
{
description = "Typesetting for Valentin's Masters Thesis";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
flake-utils.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, flake-utils }:
with flake-utils.lib; eachSystem allSystems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
tex = pkgs.texlive.combine {
inherit (pkgs.texlive) scheme-medium latexmk koma-script babel-english
physics mathtools amsmath fontspec booktabs siunitx caption biblatex float
pgfplots microtype fancyvrb csquotes setspace newunicodechar hyperref
cleveref multirow bbold unicode-math biblatex-phys xpatch beamerposter
type1cm changepage lualatex-math footmisc wrapfig2 curve2e pict2e wrapfig
appendixnumberbeamer sidecap appendix orcidlink ncctools bigfoot crop xcolor;
};
in
rec {
packages = {
watch = pkgs.writeShellScriptBin "watch-latex" ''
${tex}/bin/latexmk
while ${pkgs.inotify-tools}/bin/inotifywait --include ".*\.(sty|tex|pgf|pdf)" -e modify -r .; do
${tex}/bin/latexmk
done
'';
document = pkgs.stdenvNoCC.mkDerivation rec {
name = "masters-thesis";
src = self;
buildInputs = [ pkgs.coreutils tex pkgs.biber ];
phases = [ "unpackPhase" "buildPhase" "installPhase" ];
buildPhase = ''
export PATH="${pkgs.lib.makeBinPath buildInputs}";
mkdir -p .cache/texmf-var
mkdir -p output/src
env TEXMFHOME=.cache TEXMFVAR=.cache/texmf-var \
OSFONTDIR=${pkgs.gyre-fonts}/share/fonts:${pkgs.liberation_ttf}/share/fonts:${pkgs.lato}/share/fonts/lato:${pkgs.raleway}/share/fonts:${pkgs.lmodern}/share/fonts \
latexmk ./index.tex
'';
installPhase = ''
mkdir -p $out
cp output/index.pdf $out/
'';
};
};
defaultPackage = packages.document;
devShell = pkgs.mkShellNoCC {
buildInputs = [ packages.watch pkgs.openjdk ] ++ packages.document.buildInputs;
shellHook = ''
export OSFONTDIR=${pkgs.gyre-fonts}/share/fonts:${pkgs.liberation_ttf}/share/fonts:${pkgs.lato}/share/fonts/lato:${pkgs.raleway}/share/fonts:${pkgs.lmodern}/share/fonts
'';
};
});
}