Texdoc does not work

Hello fellow Nix-ers,

I am very new to Nix(OS) and even rather new to Linux, but I am eager to learn. It feels kind of bad to ask a “… does not work” question, but you have to start at some point.

So I just installed Tex Live on my NixOS 20.09 machine by simply adding texlive.combined.scheme-full into my configuration.nix. Unfortunately, the texdoc utility does not seem to work correctly. When I run e.g. texdoc tex, I get

$ texdoc tex`
texdoc error: No texlive.tlpdb nor shipped tlpdb data found.

The NixOS wiki page TexLive - NixOS Wiki doesn’t mention anything helpful. Maybe you know what is the issue?

Thank you very much in advance!

1 Like

I did some more research, but so far I cannot figure it out. I hope someone is willing to help a newbie out here. So I found some more documentation in the Nixpkgs manual: NixOS - Nixpkgs 21.05 manual

There it says:

For basic usage just pull texlive.combined.scheme-basic for an environment with basic LaTeX support.

So I think what I did by adding

environment.systemPackages = with pkgs; [
  ... texlive.combined.scheme-full
];

to my configuration.nix was this “basic usage” (except for using the full scheme instead of basic). Reading on in the Nixpkgs manual:

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:

texlive.combine {
  # inherit (texlive) whatever-you-want;
  pkgFilter = pkg:
    pkg.tlType == "run" || pkg.tlType == "bin" || pkg.pname == "cm-super";
  # elem tlType [ "run" "bin" "doc" "source" ]
  # there are also other attributes: version, name
}

So guessing around a little, I come to think that adding

texlive.combine = {
  inherit (texlive) scheme-full;
  pkgFilter = pkg:
    pkg.tlType == "run" || pkg.tlType == "bin" || pkg.tlType == "doc" || pkg.tlType == source;
};

somewhere should perhaps install the documentation (and everything else). The problem is, I don’t know where this code must be added. I think what I want to do here is “customizing a package” as described in the NixOS manual: NixOS - NixOS 21.05 manual
Unfortunately, the explanation given there is a little bit too terse for me, and the analogy between my code-snippet and the emacs-examples given there is not strong enough to be entirely clear to me.

Again, thank you very much in advance!

texlive.combine is a function that takes an attribute set, as you have your examples above. It will return a derivation containing the modified package.

So you place it in your systemPackages, your shells or derivations buildInputs or whereever else you can put a derivation.

Dear NobbZ,

thank you so much for your reply! After realizing that in my above post I added some syntax mistakes when modifying the sample texlive-combine function (a = in the first line, a ; in the last line and a missing " around source), I now have the following in my configuration.nix:

environment.systemPackages = with pkgs; [
  ...
    (texlive.combine {
      inherit (texlive) scheme-full;
      pkgFilter = pkg:
        pkg.tlType == "run" || pkg.tlType == "bin" || pkg.tlType == "doc" || pkg.tlType == "source";
    })
];

When rebuilding, I get:

$ sudo nixos-rebuild switch 
building Nix...
building the system configuration...
error: stack overflow (possible infinite recursion)

So I suppose I still got something wrong. Maybe you can spot where my mistake is? Also, be assured that I will continue to read the manuals and familiarize myself with the Nix language, but it would be nice to already use a NixOS machine in practice in parallel.

I currently don’t have access to my laptop, have you tried a smaller scheme?

edit

Okay, was able to try it. scheme-small evaluates within 20 seconds for me, scheme-full has the stack overflow after about 1m10s.

nix-repl> texlive.combine { inherit (texlive) scheme-small; pkgFilter = pkg: builtins.elem pkg.tlType [ "run" "bin" "doc" "source" ]; } 
«derivation /nix/store/39103284lpjha0hxwpbi9n00qfg90nnn-texlive-combined-2020.drv»
nix-repl> texlive.combine { inherit (texlive) scheme-full; pkgFilter = pkg: builtins.elem pkg.tlType [ "run" "bin" "doc" "source" ]; }
error: stack overflow (possible infinite recursion)

So I’m pretty sure, its the sheer mass of stuff that has to be filtered causes the problem.

There are 32548 components in scheme-full:

nix-repl> builtins.length texlive.scheme-full.pkgs
32548

Were you able to figure out how to make texdoc work on NixOS?