{ description = "Latex Project Report Template"; inputs = { nixpkgs.url = "github:nixos/nixpkgs"; }; outputs = { self, nixpkgs, ... }: let supportedSystems = [ "x86_64-linux" "x86_64-darwin" ]; forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system); pname = "report"; version = "0.1.0"; nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; overlays = [ self.overlay ]; } ); in rec { overlay = final: prev: { watcher = with final; pkgs.writeScriptBin "watch" '' out=".latexmkout" mkdir "$out" latexmk \ -pvc \ -outdir="$out" \ -pdf \ -pdflatex="pdflatex -interaction=nonstopmode" \ -use-make ${pname}.tex rm -r "$out" ''; buildLatex = with final; pkgs.stdenv.mkDerivation { inherit pname version; src = ./.; nativeBuildInputs = with pkgs; [ (texlive.combine { inherit (texlive) scheme-medium multirow hyperref blindtext fancyhdr etoolbox topiclongtable; }) gnumake ]; buildPhase = '' latexmk \ -pdf \ -pdflatex="pdflatex -interaction=nonstopmode" \ -use-make ${pname}.tex ''; installPhase = '' install -Dm444 -t $out ${pname}.pdf ''; }; }; packages = forAllSystems (system: { inherit (nixpkgsFor.${system}) watcher buildLatex; }); defaultPackage = forAllSystems (system: self.packages."${system}".buildLatex); apps = forAllSystems (system: { watch = { type = "app"; program = "${self.packages."${system}".watcher}/bin/watch"; }; }); }; }