Skip to content

Instantly share code, notes, and snippets.

@michaelfortunato
Last active January 9, 2025 18:14
Show Gist options
  • Save michaelfortunato/d31383627c75c4c8c96cb4c7e3bc74f2 to your computer and use it in GitHub Desktop.
Save michaelfortunato/d31383627c75c4c8c96cb4c7e3bc74f2 to your computer and use it in GitHub Desktop.
Basic Latex Flake Template
{
description = "A simple LaTeX template for writing documents with latexmk";
inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; };
outputs = { self, nixpkgs }:
let
supportedSystems =
[ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSupportedSystems = nixpkgs.lib.genAttrs supportedSystems;
in {
packages = forAllSupportedSystems (system:
let pkgs = import nixpkgs { system = system; };
in {
default = pkgs.stdenv.mkDerivation {
name = "pdf";
src = ./.;
buildInputs = [ pkgs.texliveFull ];
buildPhase = ''
mkdir -p obj
latexmk -aux-directory=obj -pdf main.tex
'';
installPhase = ''
mkdir -p $out
cp main.pdf $out
'';
};
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment