Intsalling TeXLive 2023 on NixOS

Hi everyone, first post and new NixOS convertee :).

I need help installing the TeXLive 2023 version as I need some updated packages for my work, and afaik the version on the Nix packages is from 2022. I followed the instructions on the TeXLive website and installed everything in /home/username/texlive/2023.

After installation I get these errors/warning:

Summary of warnings:
./install-tl: updmap-sys --nohash failed (status 2): 
./install-tl: fmtutil-sys --no-error-if-no-engine=luametatex,luajithbtex,luajittex,mfluajit --no-strict --all failed (status 2): 

Additionally, nothing really runs, even after setting my path (through .bashrc).
I’m not sure how to proceed, or what further information to provide. Has anyone tried doing something similar? Is there a better nix way to do this? Is there also a nix way to add to my path variables?

Thanks in advance!

Texlive contains lots of binaries, scripts and libraries with interpreter shebangs. The default texlive distribution will have all of those set to wrong paths under NixOS, and likely have other issues besides those.

The particular error you’re staring at looks like one such error, probably some scripts or libraries that cannot be executed because their interpreter is not where they expect it to be.

You can try nix-ld to resolve it, but I’d be mildly surprised if that just worked.

You could also look into what the upstream package does to untangle this, but it would probably be harder to grok and condense this just to what you need than it would be to just update the package: https://github.com/NixOS/nixpkgs/tree/nixos-23.05/pkgs/tools/typesetting/tex/texlive

Alternatively, what I have done in the past was to simply use the old texlive version, but download the specific package I needed to update from ctan manually, and then add it to the env. It’ll mask the version from the old distribution, so if it’s nothing too fundamental this can be a good workaround. I don’t recall the environment variable you need to set for that, sadly.

Finally, you can always use a VM with another distro when you get into these situations. NixOS is simply not a first class citizen for the majority of projects, we can’t always expect things to just work, having a backup distro at arm’s reach is really useful. I personally install my editor using home-manager into such VMs.

The nix way is a shell.nix or a flake devshell, the NixOS way depends a bit on your exact goal. The “idiomatic” way is to package the thing you want and add it to environment.systemPackages, but I’m pretty sure that’s not what you want.

What exactly are you trying to add to what and why?

2 Likes

I appreciate you taking the time to respond!

The particular error you’re staring at looks like one such error, probably some scripts or libraries that cannot be executed because their interpreter is not where they expect it to be.

I was hoping it would be something simpler but that makes sense!
It would probably indeed be simpler to manually update the packages I need than fix this (seems like a cool project to learn some Nix-fu though). I’ll also probably try and keep a VM handy in case I need something to “just work”, hadn’t thought of that :).

I don’t recall the environment variable you need to set for that, sadly.

I think you mean TEXINPUTS here.

What exactly are you trying to add to what and why?

In case I was going through a manual install of TeXLive, I would need to update my PATH, as simple as that! The only way I know is to just update my .bashrc, which works, but I’m unsure if I am unknowingly introducing issues this way. The same goes for setting the TEXINPUTS variable.

In place of a full VM I can highly recommend Distrobox. It works well under NixOS and basically gives you Debian/Fedora/whatever-you-need-shell in your terminal.

2 Likes

I think manually editing .bashrc is probably appropriate in this case. You have other options:

  1. Package texlive 2023 instead of manually installing it and add it to environment.systemPackages
    • This is probably the idiomatic NixOS way, but we’ve asserted it’s nontrivial, so not really an option.
  2. Use home-manager to add that to your shell init files instead of doing it manually
    • There’s no effective difference, you don’t gain any benefit by declaratively setting this because you’ll need to go through the manual texlive installation anyway. Sensible if you already use home-manager for shell init though.
  3. Use environment.variables to set the variables
    • Similar to setting it through home-manager, except the variables will be set system-wide. Probably not desirable, and I don’t know how this interacts with PATH being set by other things.

Things to consider are whether to use .bashrc or .profile/.bash_profile. .bashrc will only apply to interactive terminals, so if you have any scripts that run in a session that didn’t inherit from an interactive terminal, your path will suddenly be wrong. The others will only work with login shells, on the other hand, which will cause other issues. Shell env setup can be needlessly complicated.

This is probably more doable though. You could do something like:

# configuration.nix
{ pkgs, ... }: {
  environment.variables.TEXINPUTS = (pkgs.fetchurl {
    url = "<URL to file on ctan>";
    hash = "<hash>";
  }).outPath;
}

To download the input and set the TEXINPUTS variable to its path in the nix store. Then you have a declarative, reproducible config that installs this input for you.

You could even do this in a shell.nix so you don’t infect your system installation with this:

# shell.nix
{ pkgs ? import <nixpkgs>, ... }: let
  some-tex-input = pkgs.fetchurl {
    url = "<URL to file on ctan>";
    hash = "<hash>";
  };
in pkgs.mkShell {
  shellHook = ''
    export TEXINPUTS="${some-tex-input}:$TEXINPUTS"
  '';
}
2 Likes

Thanks for the additional insight! I will definitely return to this post as I learn more about how to set things up better instead of band-aid-ing things. For now at least, my workflow is not disrupted :slight_smile:

1 Like