Problem installing fonts on NixOS WSL-2 distro

I’m running NixOS 26.05 (Yarara) NixOS under WSL-2 and in my home.nix I have defined:

Fonts

fonts = {
fontconfig = {
enable = true;

  defaultFonts = {
    serif = [
      "Liberation Serif"
      "Vazirmatn"
    ];
    sansSerif = [
      "Ubuntu"
      "Vazirmatn"
    ];
    monospace = [
      "Ubuntu Mono"
      "JetBrainsMono Nerd Font"
    ];
  };
};

};

In my packages I have

home.packages = with pkgs; [
noto-fonts
noto-fonts-cjk-sans
noto-fonts-color-emoji
liberation_ttf
fira-code
fira-code-symbols
mplus-outline-fonts.githubRelease
nerdfix
dina-font

I did a rebuild:

“sudo nixos-rebuild boot --flake /mnt/wsl/projects/git/dotfiles/nixos-wsl/nixos/#nixos

and got a new configuration created

I did

fc-cache -f -v

but

fc-list
/nix/store/1a05sfbahpf31hlvlq48czd95hffcwv4-dejavu-fonts-minimal-2.37/share/fonts/truetype/DejaVuSans.ttf: DejaVu Sans:style=Book

Is only showing

/nix/store/1a05sfbahpf31hlvlq48czd95hffcwv4-dejavu-fonts-minimal-2.37/share/fonts/truetype/DejaVuSans.ttf: DejaVu Sans:style=Book

What am I doing wrong

Have you restarted WSL after running this and how are you using home-manager?

Yes, I tried restarting WSL-2 did not help

I have a flake.nix which includes my home.nix

home-manager.users.mwoodpatrick = import ./home.nix;

Is there a config file in ~/.config/fontconfig/conf.d/, if so could you share it?

Where in your flake.nix is home-manager.users.mwoodpatrick = import ./home.nix;? (just to make sure you’re using home-manager correctly)

I resolved my issue by moving the font specification from home.nix to configuration.nix

dotfiles/nixos-wsl/nixos at wsl · mwoodpatrick/dotfiles

1 Like