Manual for Pijul
{ stdenv
, mdbook
, pdf2svg
, texlive
}:

stdenv.mkDerivation {
  pname = "pijul-manual";
  version = "draft";
  src = ./.;

  buildInputs = [ mdbook pdf2svg texlive.combined.scheme-small ];

  buildPhase = ''
    cd src
    pdflatex -shell-escape figures
    rm -f figures *.dpth *.log *.md5
    for file in $(ls *.pdf); do
       pdf2svg $file $(basename $file .pdf).svg
    done
    cd ..
    mdbook build
  '';

  installPhase = ''
    mkdir $out
    cp -R book/* $out #*/
  '';
}