How to search package contents

Hi all,

I just installed TexLive via Nix with the package texliveSmall. When I try to compile a document from the Nix shell I get errors with missing style files. I would need to identify the package(s) containing a particular file, e.g. elsarticle.cls. I tried the dumb search at search.nixos.org but it returns zero results. How can it be made?

Thank you.

This can be done via the nix-locate command included in the nix-index package.

For example you could do:

# Update local database or initialise it if run for the first time
nix-index

# Search for a specific file (requires that the databasr from nix-index exist)
nix-locate elsarticle.cls

You can also make use of the pregenerated database at GitHub - nix-community/nix-index-database: Weekly updated nix-index database [maintainer=@Mic92]

1 Like

@jopejoe1 That looks like a solution, however, none of those tools are currently installed. Should they be part of the Nix installation?

Nope they are not part of the regular installation, but are included in the nix-index package which can be installed like any other package or in a tempory shell with nix-shell -p nix-index

I ran nix-shell -p nix-index and then nix-index. And the system became unresponsive. From what I understand nix-index exhausted available RAM (about 8 GB free at the time).

Looks like these tools are not mature. Is there any alternative?

It does take a few minutes, to generate the database.

An alternative would be to use GitHub - nix-community/nix-index-database: Weekly updated nix-index database [maintainer=@Mic92] which you can use like this if you have flakes enabled:

nix run github:nix-community/nix-index-database elsarticle.cls

I need a bit more verbiage, but it eventually worked with:
nix --extra-experimental-features nix-command --extra-experimental-features flakes run github:nix-community/nix-index-database elsarticle.cls

This was the output:

(texliveFull.out)                                44,541 r /nix/store/32d6rsqc79hv0vs5zkcwvwprr0qms0s1-elsarticle-3.3-tex/tex/latex/elsarticle/elsarticle.cls
perl538Packages.LaTeXML.out                       3,084 r /nix/store/xx6ki3q66vdh5bf07zzblmxysbiwlmdg-perl5.38.2-LaTeXML-0.8.8/lib/perl5/site_perl/5.38.2/LaTeXML/Package/elsarticle.cls.ltxml
perl536Packages.LaTeXML.out                       3,084 r /nix/store/3f8n0vb9dnvhw7x74lfnz2dqni6p13jm-perl5.36.3-LaTeXML-0.8.8/lib/perl5/site_perl/5.36.3/LaTeXML/Package/elsarticle.cls.ltxml

If I read this correctly, texliveFull includes this file. The following two lines represent exactly what? Other packages?

Thank you.

can be shortened to

nix --experimental-features 'nix-command flakes' run github:nix-community/nix-index-database elsarticle.cls