I'm using nix to set up a little environment I can use for latex. I want to compile a small standalone document with tikz drawing. So I have this minimal tex file:
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw(0,0)circle(8);
\end{tikzpicture}
\end{document}
This should need the pgf
package for tikz
and the standalone
package for standalone
. So I have my nix.shell
{ pkgs ? import <nixpkgs> {} }:
let
tex =
pkgs.texlive.combine
{ inherit (pkgs.texlive) scheme-minimal pgf standalone;
};
in
pkgs.mkShell
{ nativeBuildInputs =
[ tex
];
}
If I run my shell and attempt to compile with pdflatex
:
[nix-shell:~/Projects/Tex]$ pdflatex example.tex
This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021/NixOS.org) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./example.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-02-24>
! LaTeX Error: File `standalone.cls' not found.
It seems that latex is not aware of the packages, which isn't very surprising. But I don't really know how to do this. I've looked at texlive on the nixos wiki which doesn't say very much. They have an example which looks like what I have other than the fact it is using the home manager.
How do I make the packages installed via nix available for pdflatex?
I'm not sure why, but pdflatex
is not available in scheme-minimal
(even though pdftex
is available). This can be verified with pure nix-shell:
$ nix-shell --pure
[nix-shell:~]$ pdflatex
The program 'pdflatex' is not in your PATH. It is provided by several packages.
You can make it available in an ephemeral shell by typing one of the following:
nix-shell -p tetex
nix-shell -p texlive.combined.scheme-basic
nix-shell -p texlive.combined.scheme-full
nix-shell -p texlive.combined.scheme-gust
nix-shell -p texlive.combined.scheme-medium
nix-shell -p texlive.combined.scheme-small
nix-shell -p texlive.combined.scheme-tetex
What happens in your case is that you run pdflatex from your main system, which does not have standalone
available. If you change scheme-minimal
to scheme-small
, pdflatex
will be available in the shell and everything will work.