diff --git a/.gitignore b/.gitignore index 34ada5a..f63658a 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ *.vrb *.aux *.xmpi +*.lock diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ba39560 --- /dev/null +++ b/flake.nix @@ -0,0 +1,78 @@ +{ + description = "Build LaTeX Academic CV - Matt Morin"; + inputs = { + nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable; + flake-utils.url = github:numtide/flake-utils; + }; + 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-basic + latexmk + fontawesome5 + accsupp + geometry + xparse + scrlfile + tikex + hyperref + arrows + inline + fontspec + cmap + inputenc + fontenc + tikz + tcolorbox + enumitem + graphicx + trimclip + dashrule + multirow + tabularx + changepage + afterpage + pgffor; + }; + in rec { + packages = { + document = pkgs.stdenvNoCC.mkDerivation rec { + name = "cv-document"; + src = self; + propagatedBuildInputs = [ pkgs.coreutils pkgs.fontawesome5 tex ]; + phases = ["unpackPhase" "buildPhase" "installPhase"]; + SCRIPT = '' + #!/bin/bash + prefix=${builtins.placeholder "out"} + export PATH="${pkgs.lib.makeBinPath propagatedBuildInputs}"; + DIR=$(mktemp -d) + RES=$(pwd)/document.pdf + cd $prefix/share + mkdir -p "$DIR/.texcache/texmf-var" + env TEXMFHOME="$DIR/.cache" \ + TEXMFVAR="$DIR/.cache/texmf-var" \ + OSFONTDIR=${pkgs.fontawesome5}/share/fonts \ + latexmk -interaction=nonstopmode -pdf -lualatex \ + -output-directory="$DIR" \ + -pretex="\pdfvariable suppressoptionalinfo 512\relax" \ + cv.tex + mv "$DIR/document.pdf" $RES + rm -rf "$DIR" + ''; + buildPhase = '' + printenv SCRIPT > cv-document + ''; + installPhase = '' + mkdir -p $out/{bin,share} + cp cv.tex $out/share/cv.tex + cp cv-document $out/bin/build-cv + chmod +x $out/bin/build-cv + ''; + }; + }; + defaultPackage = packages.document; + }); +}