How to install Latex package tikz

I have a Latex file which includes


When I try to process this file with pdflatex, processing stops with

! LaTeX Error: File `tikz.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name:

My environment.systempackages includes both texlive.combined.scheme-full and tikzit. Am I simply not including the right package, or is there more to it than that?

You have to use texlive.combine to create a new package that combines all LaTeX packages into an environment:

environment.systemPackages = [
  # other packages...

  (pkgs.texlive.combine {
    inherit (pkgs.texlive)

Thanks for the reply but with

            (pkgs.texlive.combine {
              inherit (pkgs.texlive) scheme-full tikz ;

I get:

[root@pingala:~]# nixos-rebuild switch
building Nix...
building the system configuration...
error: attribute 'tikz' missing, at /etc/nixos/configuration.nix:122:40
(use '--show-trace' to show detailed location information)

Sorry, I used the package name you were using, I didn’t pay much attention.

If you want to install all of LaTeX (which is huge, like 5 GB) then you should use:


Then you will have all packages available.

But I don’t think that’s necessary, you can install a smaller set and then add the missing packages with the texlive.combine function that I mentioned:

(pkgs.texlive.combine { inherith (pkgs.texlive) scheme-small pgf; })

The pgf package is the one that contains tikz.

But also, you don’t need to install it globally and can use nix-shell with per-project packages, creating a shell.nix file with this content:

with import <nixpkgs> {};

mkShell {
  packages = [
    (texlive.combine {
      # etc

Nope, there must be something else going wrong because with

           (pkgs.texlive.combine {
              inherit (pkgs.texlive) scheme-full pgf ;

I still get:

! LaTeX Error: File `tikz.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name:


[mounty@pingala:~]$ find / -name 'tikz.sty' 2>/dev/null

so the package is there but for some reason is not put where Latex expects to find it.

Is it possible that you add a version of TeXLive that does not include pgf to the environment somewhere else in your configuration?

If you run which -a pdflatex, it should only return one line. Otherwise there are multiple TeXLive packages in the environment, one of them should be the one including tikz.sty (you can try running the pdflatex binaries that which returns, one should successfully compile the file).

Also, according to the Wiki, scheme-full “Contains every TeX Live package”, so there is no need to combine it with pgf, it should work as-is. Though using the full scheme might have a negative impact on evaluation performance and memory usage, which is why I personally only use TeXLive with nix-shell.

1 Like

Yes, it is possible, and thank you for providing the clue to the solution. I tried:

[mounty@pingala:~]$ ls -l $(which pdflatex)
lrwxrwxrwx 1 root root 66 Jan  1  1970 /home/mounty/.nix-profile/bin/pdflatex -> /nix/store/zvnrlksphnm9kj2pzmwy3fxk2r0av3k8-tetex-3.0/bin/pdflatex

which made me realise that my pdflatex was coming from the tetex package that I installed long ago and then removed from my systemPackages list. So:

[mounty@pingala:~]$ nix-env --uninstall tetex

and now pdflatex works. Thank you!

[mounty@pingala:~]$ ls -l $(which pdflatex)   
lrwxrwxrwx 1 root root 78 Jan  1  1970 /run/current-system/sw/bin/pdflatex -> /nix/store/jlyw2nnbbn0zi1shx95jbdk7yjdfpfd2-texlive-combined-2021/bin/pdflatex
1 Like