Nix flake template for LaTeX documents, built on purr and git-hooks.nix. Part of develop-templates.
Initialize in the current directory:
nix flake init -t "github:nixcafe/develop-templates#latex" --refreshOr register the template flake once under beans:
nix registry add beans "github:nixcafe/develop-templates"
nix flake init -t beans#latexIf you use cattery-modules, beans is already registered.
To create a new GitHub repository directly:
gh repo create my-latex-project --template nixcafe-develop/latex --cloneEnter the shell:
direnv allow
# or
nix developNo flake.lock is shipped. The first Nix command generates one.
latexmk -pdf main.texThis writes main.pdf. PDF files and intermediate TeX outputs are ignored in .gitignore.
| Tool | Role |
|---|---|
texliveMedium |
TeX Live medium scheme |
latexmk |
Build runner |
texlab |
LaTeX LSP server |
chktex |
LaTeX linter |
latexindent |
LaTeX formatter |
minted |
Code highlighting via Pygments |
nixfmt |
Formats Nix files (nix fmt) |
deadnix |
Finds unused Nix bindings |
statix |
Lints Nix files |
upquote is included alongside minted, so minted works out of the box without adding extra Python packages.
Pre-commit hooks for nixfmt, deadnix, and statix live in develop/checks/git-hooks/default.nix and install when you enter the shell.
.
├── .envrc
├── .gitignore
├── flake.nix
├── main.tex
├── statix.toml
└── develop/
├── checks/
│ └── git-hooks/
│ └── default.nix
└── shells/
└── default/
└── default.nix
Edit tex in develop/shells/default/default.nix:
tex = pkgs.texliveMedium.withPackages (
ps: with ps; [
latexmk
minted
upquote
latexindent
chktex
biblatex
]
);Swap pkgs.texliveMedium for pkgs.texliveSmall (smaller install) or pkgs.texliveFull (all packages) as needed.
Add packages in develop/shells/default/default.nix:
packages = with pkgs; [
tex
texlab
nixfmt
deadnix
statix
inkscape
];nix develop # open dev shell
latexmk -pdf main.tex # build main.pdf
latexmk -C # clean build artifacts
nix fmt # format Nix files
nix flake check # run git-hooks check