Texdoc cannot find texlive.tlpdb

I install texlive by home-manager like this:

    texlive = {
      enable = true;
      extraPackages = tpkgs: {
        inherit (tpkgs) scheme-medium collection-latexextra
          collection-bibtexextra collection-publishers collection-langchinese;
        pkgFilter = (pkg: with lib; with pkg;
          elem tlType [ "run" "bin" "doc" ] ||
          elem pname  [ "core" ]);

I can find the document of texlive packages under /nix/store/.*-texlive-.*\.doc. But I cannot use texdoc to open a helping document quickly. It listed error as following:

$ texdoc texdoc                                                                                                                                         /nix/store/cph70fq2lhhjilgnms45pjw3r5pl5rpk-texlive-texdoc.doc-3.2.1/doc/support/texdoc
texdoc error: No texlive.tlpdb nor shipped tlpdb data found.

I find overrides of texlive.tlpdb commented in <nixpkgs/pkgs/tools/typesetting/tex/texlive/default.nix>. Dose this means I cannot use texdoc installed by nix? Or what should I do to make it work.

Did you find how to solve this issue? I installed LaTeX by simply installing texlive.combined.scheme-full, but I’m not sure what to do next.

– EDIT –
Related: texlive: how to get texdoc to work? · Issue #118757 · NixOS/nixpkgs · GitHub and texlive: Refactors toward working texdoc by bb010g · Pull Request #120578 · NixOS/nixpkgs · GitHub

This isn’t trivial. As of now, nixpkgs does not have the right pieces to make texdoc work out of the box.

You might be able to make it work if

  1. you download texlive.tlpdb.xz (matching the current snapshot in nixpkgs, see nixpkgs/default.nix at f4ca9882ffe4217d456be038961495540ed7414c · NixOS/nixpkgs · GitHub),
  2. call texlive.combine with a custom pkgFilter so that it install packages with tlType == "doc" (you should only allow "doc" for the packages you really need – the docs take a tons of space and are not cached, so you’ll have to build them locally),
  3. point texdoc at your uncompressed texlive.tlpdb (see page 15 of https://www.tug.org/texdoc/doc/texdoc.pdf).

I haven’t tried, but in principle, it should work.

Ideally, nixpkgs should ship the file Data.tlpdb.lua together with texdoc (here are the commands to generate it texdoc/Rakefile at a16bef1b0a978fd0cbc88b3ad0887cbc08c07a1a · TeX-Live/texdoc · GitHub) so that you can skip steps 1 and 3. The hard part, for me at least, is figuring out where to do this in texlive. Maybe this could be a fake package, forced in as an additional dependency of texdoc.

Found a moment to test the procedure, and it works! The exact details:

  1. Download https://texlive.info/tlnet-archive/2021/04/08/tlnet/tlpkg/texlive.tlpdb.xz (the date must match the snapshot distributed in your channel).
  2. Uncompress: unxz texlive.tlpdb.xz.
  3. Run texdoc -c texlive_tlpdb=texlive.tlpdb texdoc.

For instance:

$ texdoc -c texlive_tlpdb=texlive.tlpdb -l texdoc
 1 /nix/store/xs5s9bpna1854zfc01zpr2wahyw1chc3-texlive-combined-2021/share/texmf/doc/support/texdoc/texdoc.pdf
   = Package documentation
 2 /nix/store/xs5s9bpna1854zfc01zpr2wahyw1chc3-texlive-combined-2021/share/texmf/doc/support/texdoc/README.md
   = Readme
 3 /nix/store/xs5s9bpna1854zfc01zpr2wahyw1chc3-texlive-combined-2021/share/texmf/doc/support/texdoc/NEWS
 4 /nix/store/xs5s9bpna1854zfc01zpr2wahyw1chc3-texlive-combined-2021/share/texmf/doc/man/man1/texdoc.man1.pdf
Enter number of file to view, RET to view 1, anything else to skip: 2
1 Like

Do you need to repeat the process anytime you upgrade LaTeX?