1# TeX Live {#sec-language-texlive} 2 3Since release 15.09 there is a new TeX Live packaging that lives entirely under attribute `texlive`. 4 5## User's guide {#sec-language-texlive-user-guide} 6 7- For basic usage just pull `texlive.combined.scheme-basic` for an environment with basic LaTeX support. 8 9- 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: 10 11 ```nix 12 texlive.combine { 13 inherit (texlive) scheme-small collection-langkorean algorithms cm-super; 14 } 15 ``` 16 17- There are all the schemes, collections and a few thousand packages, as defined upstream (perhaps with tiny differences). 18 19- 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`. 20 21 ```nix 22 texlive.combine { 23 # inherit (texlive) whatever-you-want; 24 pkgFilter = pkg: 25 pkg.tlType == "run" || pkg.tlType == "bin" || pkg.pname == "cm-super"; 26 # elem tlType [ "run" "bin" "doc" "source" ] 27 # there are also other attributes: version, name 28 } 29 ``` 30 31- You can list packages e.g. by `nix repl`. 32 33 ```ShellSession 34 $ nix repl 35 nix-repl> :l <nixpkgs> 36 nix-repl> texlive.collection-[TAB] 37 ``` 38 39- 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. 40 41## Custom packages {#sec-language-texlive-custom-packages} 42 43 44You may find that you need to use an external TeX package. A derivation for such package has to provide contents of the "texmf" directory in its output and provide the `tlType` attribute. Here is a (very verbose) example: 45 46```nix 47with import <nixpkgs> {}; 48 49let 50 foiltex_run = stdenvNoCC.mkDerivation { 51 pname = "latex-foiltex"; 52 version = "2.1.4b"; 53 passthru.tlType = "run"; 54 55 srcs = [ 56 (fetchurl { 57 url = "http://mirrors.ctan.org/macros/latex/contrib/foiltex/foiltex.dtx"; 58 sha256 = "07frz0krpz7kkcwlayrwrj2a2pixmv0icbngyw92srp9fp23cqpz"; 59 }) 60 (fetchurl { 61 url = "http://mirrors.ctan.org/macros/latex/contrib/foiltex/foiltex.ins"; 62 sha256 = "09wkyidxk3n3zvqxfs61wlypmbhi1pxmjdi1kns9n2ky8ykbff99"; 63 }) 64 ]; 65 66 unpackPhase = '' 67 runHook preUnpack 68 69 for _src in $srcs; do 70 cp "$_src" $(stripHash "$_src") 71 done 72 73 runHook postUnpack 74 ''; 75 76 nativeBuildInputs = [ texlive.combined.scheme-small ]; 77 78 dontConfigure = true; 79 80 buildPhase = '' 81 runHook preBuild 82 83 # Generate the style files 84 latex foiltex.ins 85 86 runHook postBuild 87 ''; 88 89 installPhase = '' 90 runHook preInstall 91 92 path="$out/tex/latex/foiltex" 93 mkdir -p "$path" 94 cp *.{cls,def,clo} "$path/" 95 96 runHook postInstall 97 ''; 98 99 meta = with lib; { 100 description = "A LaTeX2e class for overhead transparencies"; 101 license = licenses.unfreeRedistributable; 102 maintainers = with maintainers; [ veprbl ]; 103 platforms = platforms.all; 104 }; 105 }; 106 foiltex = { pkgs = [ foiltex_run ]; }; 107 108 latex_with_foiltex = texlive.combine { 109 inherit (texlive) scheme-small; 110 inherit foiltex; 111 }; 112in 113 runCommand "test.pdf" { 114 nativeBuildInputs = [ latex_with_foiltex ]; 115 } '' 116cat >test.tex <<EOF 117\documentclass{foils} 118 119\title{Presentation title} 120\date{} 121 122\begin{document} 123\maketitle 124\end{document} 125EOF 126 pdflatex test.tex 127 cp test.pdf $out 128'' 129```