Last active
January 9, 2025 18:14
-
-
Save michaelfortunato/d31383627c75c4c8c96cb4c7e3bc74f2 to your computer and use it in GitHub Desktop.
Basic Latex Flake Template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
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