master-thesis-tex/flake.nix

55 lines
2 KiB
Nix
Raw Normal View History

2022-06-20 21:43:27 +02:00
{
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;
};
in rec {
packages = {
2022-06-28 20:33:44 +02:00
watch = pkgs.writeShellScriptBin "watch-latex" ''
${tex}/bin/latexmk
while ${pkgs.inotify-tools}/bin/inotifywait --include ".*\.(sty|tex)" -e modify -r .; do
${tex}/bin/latexmk
done
'';
2022-06-20 21:43:27 +02:00
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
env TEXMFHOME=.cache TEXMFVAR=.cache/texmf-var \
OSFONTDIR=${pkgs.gyre-fonts}/share/fonts \
latexmk -interaction=nonstopmode \
./index.tex
'';
installPhase = ''
mkdir -p $out
2022-06-28 20:33:44 +02:00
cp output/index.pdf $out/
2022-06-20 21:43:27 +02:00
'';
};
};
defaultPackage = packages.document;
2022-06-28 20:33:44 +02:00
devShell = pkgs.mkShellNoCC {
buildInputs = [packages.watch] ++ packages.document.buildInputs;
shellHook = ''
export OSFONTDIR=${pkgs.gyre-fonts}/share/fonts:${pkgs.liberation_ttf}/share/fonts
'';
};
2022-06-20 21:43:27 +02:00
});
}