1 # TeX Live {#sec-language-texlive}
3 Since release 15.09 there is a new TeX Live packaging that lives entirely under attribute `texlive`.
5 ## User's guide (experimental new interface) {#sec-language-texlive-user-guide-experimental}
7 Release 23.11 ships with a new interface that will eventually replace `texlive.combine`.
9 - For basic usage, use some of the prebuilt environments available at the top level, such as `texliveBasic`, `texliveSmall`. For the full list of prebuilt environments, inspect `texlive.schemes`.
11 - Packages cannot be used directly but must be assembled in an environment. To create or add packages to an environment, use
13 texliveSmall.withPackages (ps: with ps; [ collection-langkorean algorithms cm-super ])
15 The function `withPackages` can be called multiple times to add more packages.
17 - **Note.** Within Nixpkgs, packages should only use prebuilt environments as inputs, such as `texliveSmall` or `texliveInfraOnly`, and should not depend directly on `texlive`. Further dependencies should be added by calling `withPackages`. This is to ensure that there is a consistent and simple way to override the inputs.
19 - `texlive.withPackages` uses the same logic as `buildEnv`. Only parts of a package are installed in an environment: its 'runtime' files (`tex` output), binaries (`out` output), and support files (`tlpkg` output). Moreover, man and info pages are assembled into separate `man` and `info` outputs. To add only the TeX files of a package, or its documentation (`texdoc` output), just specify the outputs:
21 texlive.withPackages (ps: with ps; [
22 texdoc # recommended package to navigate the documentation
23 perlPackages.LaTeXML.tex # tex files of LaTeXML, omit binaries
25 cm-super.texdoc # documentation of cm-super
29 - All packages distributed by TeX Live, which contains most of CTAN, are available and can be found under `texlive.pkgs`:
32 nix-repl> :l <nixpkgs>
33 nix-repl> texlive.pkgs.[TAB]
35 Note that the packages in `texlive.pkgs` are only provided for search purposes and must not be used directly.
37 - **Experimental and subject to change without notice:** to add the documentation for all packages in the environment, use
39 texliveSmall.__overrideTeXConfig { withDocs = true; }
41 This can be applied before or after calling `withPackages`.
43 The function currently support the parameters `withDocs`, `withSources`, and `requireTeXPackages`.
45 ## User's guide {#sec-language-texlive-user-guide}
47 - For basic usage just pull `texlive.combined.scheme-basic` for an environment with basic LaTeX support.
49 - It typically won't work to use separately installed packages together. Instead, you can build a custom set of packages like this. Most CTAN packages should be available:
53 inherit (texlive) scheme-small collection-langkorean algorithms cm-super;
57 - There are all the schemes, collections and a few thousand packages, as defined upstream (perhaps with tiny differences).
59 - By default you only get executables and files needed during runtime, and a little documentation for the core packages. To change that, you need to add `pkgFilter` function to `combine`.
63 # inherit (texlive) whatever-you-want;
65 pkg.tlType == "run" || pkg.tlType == "bin" || pkg.hasManpages || pkg.pname == "cm-super";
66 # elem tlType [ "run" "bin" "doc" "source" ]
67 # there are also other attributes: version, name
71 - You can list packages e.g. by `nix repl`.
75 nix-repl> :l <nixpkgs>
76 nix-repl> texlive.collection-[TAB]
79 - Note that the wrapper assumes that the result has a chance to be useful. For example, the core executables should be present, as well as some core data files. The supported way of ensuring this is by including some scheme, for example `scheme-basic`, into the combination.
81 - TeX Live packages are also available under `texlive.pkgs` as derivations with outputs `out`, `tex`, `texdoc`, `texsource`, `tlpkg`, `man`, `info`. They cannot be installed outside of `texlive.combine` but are available for other uses. To repackage a font, for instance, use
84 stdenvNoCC.mkDerivation rec {
85 src = texlive.pkgs.iwona;
88 inherit (src) pname version;
92 install -Dm644 $src/fonts/opentype/nowacki/iwona/*.otf -t $out/share/fonts/opentype
98 See `biber`, `iwona` for complete examples.
100 ## Custom packages {#sec-language-texlive-custom-packages}
102 You may find that you need to use an external TeX package. A derivation for such package has to provide the contents of the "texmf" directory in its `"tex"` output, according to the [TeX Directory Structure](https://tug.ctan.org/tds/tds.html). Dependencies on other TeX packages can be listed in the attribute `tlDeps`.
104 The functions `texlive.combine` and `texlive.withPackages` recognise the following outputs:
106 - `"out"`: contents are linked in the TeX Live environment, and binaries in the `$out/bin` folder are wrapped;
107 - `"tex"`: linked in `$TEXMFDIST`; files should follow the TDS (for instance `$tex/tex/latex/foiltex/foiltex.cls`);
108 - `"texdoc"`, `"texsource"`: ignored by default, treated as `"tex"`;
109 - `"tlpkg"`: linked in `$TEXMFROOT/tlpkg`;
110 - `"man"`, `"info"`, ...: the other outputs are combined into separate outputs.
112 When using `pkgFilter`, `texlive.combine` will assign `tlType` respectively `"bin"`, `"run"`, `"doc"`, `"source"`, `"tlpkg"` to the above outputs.
114 Here is a (very verbose) example. See also the packages `auctex`, `eukleides`, `mftrace` for more examples.
117 with import <nixpkgs> {};
120 foiltex = stdenvNoCC.mkDerivation {
121 pname = "latex-foiltex";
124 outputs = [ "tex" "texdoc" ];
125 passthru.tlDeps = with texlive; [ latex ];
129 url = "http://mirrors.ctan.org/macros/latex/contrib/foiltex/foiltex.dtx";
130 hash = "sha256-/2I2xHXpZi0S988uFsGuPV6hhMw8e0U5m/P8myf42R0=";
133 url = "http://mirrors.ctan.org/macros/latex/contrib/foiltex/foiltex.ins";
134 hash = "sha256-KTm3pkd+Cpu0nSE2WfsNEa56PeXBaNfx/sOO2Vv0kyc=";
141 for _src in $srcs; do
142 cp "$_src" $(stripHash "$_src")
148 nativeBuildInputs = [
149 (texliveSmall.withPackages (ps: with ps; [ cm-super hypdoc latexmk ]))
150 # multiple-outputs.sh fails if $out is not defined
151 (writeShellScript "force-tex-output.sh" ''
156 dontConfigure = true;
161 # Generate the style files
164 # Generate the documentation
166 latexmk -pdf foiltex.dtx
174 path="$tex/tex/latex/foiltex"
176 cp *.{cls,def,clo,sty} "$path/"
178 path="$texdoc/doc/tex/latex/foiltex"
186 description = "LaTeX2e class for overhead transparencies";
187 license = lib.licenses.unfreeRedistributable;
188 maintainers = with lib.maintainers; [ veprbl ];
189 platforms = lib.platforms.all;
193 latex_with_foiltex = texliveSmall.withPackages (_: [ foiltex ]);
195 runCommand "test.pdf" {
196 nativeBuildInputs = [ latex_with_foiltex ];
199 \documentclass{foils}
201 \title{Presentation title}
213 ## LuaLaTeX font cache {#sec-language-texlive-lualatex-font-cache}
215 The font cache for LuaLaTeX is written to `$HOME`.
216 Therefore, it is necessary to set `$HOME` to a writable path, e.g. [before using LuaLaTeX in nix derivations](https://github.com/NixOS/nixpkgs/issues/180639):
218 runCommandNoCC "lualatex-hello-world" {
219 buildInputs = [ texliveFull ];
222 echo '\documentclass{article} \begin{document} Hello world \end{document}' > main.tex
223 env HOME=$(mktemp -d) lualatex -interaction=nonstopmode -output-format=pdf -output-directory=$out ./main.tex
227 Additionally, [the cache of a user can diverge from the nix store](https://github.com/NixOS/nixpkgs/issues/278718).
228 To resolve font issues that might follow, the cache can be removed by the user:
230 luaotfload-tool --cache=erase --flush-lookups --force