3

I have figured out that I need CMU fonts to be able to typeset Russian text with XeLaTeX. Under NixOS there is cm-unicode package for it, I have installed it with

nix-env -iA nixos.cm_unicode

but XeLaTeX still cannot find it. A LaTeX file that I can compile with XeLaTeX on Ubuntu does not compile with XeLaTeX on NixOS, and I get an error that the CMU font that I indicated was not found.

I've learned that I could list all fonts installed on the system with fc-list, so I tried running fc-list | grep -i cmu, fc-list | grep -i com, fc-list | grep -i unic, but got no results.

How can I get this font installed? This is for NixOS 17.09.


By the way, I have already had to manually install Latin Modern font: it was initially not available for selection in XeLaTeX, but after I installed lmodern package with nix-env -i, it works fine.

I have just tested this again: uninstalling lmodern with nix-env -e removes Latin Modern from the results of fc-list and from font-manager, and installing with nix-env -i restores it. The same does not work the same with cm_unicode.


I have a possibly related question, so I'll put it here. (If it turns out that it is not related, I would appreciate a short comment or explanation.)

I wanted to define my TeX Live environment with all its dependencies in my .nixpkgs/config.nix, so I did

# .nixpkgs/config.nix
{ # ...
  packageOverrides = pkgs: {
    myTexLive = pkgs.texlive.combine {
      inherit (pkgs.texlive) scheme-basic
                             collection-bibtexextra
                             collection-fontsrecommended
                             collection-genericrecommended
                             collection-langcyrillic
                             collection-langfrench
                             collection-latex
                             collection-latexextra
                             collection-latexrecommended
                             collection-mathextra
                             collection-xetex
                             cm-unicode  # from `collection-fontsextra`
                             latexmk
                             lm       # from `collection-fontsrecommended`
                             lm-math  # from `collection-fontsrecommended`
                             texdoc;
    };
}

I was hoping that having lm and cm-unicode TeX Live packages would be enough to have the Latin Modern and CMU fonts install, but it did not work.

Is there any way to declare the necessary fonts as dependencies of myTexLive?

3

On NixOS fonts cannot be installed via nix-env because for fonts to be found a database of sorts needs to be created. That requires side-effects, yet Nix packages are pure functions. In general, you can think of side-effecting code as being handled by nixos-rebuild; hence you'll need to use configuration.nix:

fonts.fonts = [ pkgs.cm_unicode ];

You can watch my video on NixOS fonts for a demonstration. Pardon my robot-voice.

For Latex-specific info, see https://nixos.org/nixpkgs/manual/#sec-language-texlive

  • Thanks, i will try and report back. However, i remember that after installing TeXLive, there were no Latin Modern either, and i installed it with nix-env -iA nixos.lmodern. Also, Latin Modern shows up in the results of fc-list. Can you explain this difference? Should i also reinstall lmodern via configuration.nix? – Alexey Mar 1 '18 at 7:23
  • Adding cm_super to fonts.fonts in configuration.nix worked indeed. Can you comment on the difference between lmodern and cm_unicode? (I edited the question.) If lmodern works when installed with nix-env, should i still declare it in configuration.nix to avoid problems? Is it possible to install a font for just one user? – Alexey Mar 1 '18 at 11:28
  • In short: I don't know. You can check what depends on lmodern by first identifying the store path (/nix/store/blah-lmodern-blah) and then feeding it into nix-store -q --referrers PATH. As far as I know, the font cache is build by the NixOS font module and it operates system-wide; So no, font's are system, not user specific. For instance, if you follow the link /etc/fonts you'll see it results in a single path; there's no Nix profile involved. I recommend using configuration.nix for all fonts. – Emmanuel Rosa Mar 1 '18 at 13:53
  • Can you include this additional info into your answer, please? – Alexey Mar 1 '18 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.