Fontconfig errors when launching emacs

I am using nix 2.3.1 on Ubuntu 19.10. I am using nix channel:

nixpkgs-unstable release nixpkgs-21.11pre326916.7053541084b

I installed emacs 26.3 using:

nix-env -iA nixpkgs.emacs

When I launch emacs I get the following errors:

(process:9100): Gtk-WARNING **: 09:41:39.668: Locale not supported by C library.
	Using the fallback 'C' locale.
Gtk-Message: 09:41:39.756: Failed to load module "canberra-gtk-module"
Gtk-Message: 09:41:39.756: Failed to load module "canberra-gtk-module"
Fontconfig warning: "/etc/fonts/fonts.conf", line 5: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/fonts.conf", line 6: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/fonts.conf", line 6: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/fonts.conf", line 6: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/fonts.conf", line 7: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/fonts.conf", line 7: invalid attribute 'version'
Fontconfig warning: "/etc/fonts/fonts.conf", line 9: unknown element "description"
Fontconfig error: Cannot load config file from /etc/fonts/fonts.conf

How do I fix this?

Sounds like you need an overlay. I don’t use Emacs, but here’s an example for VScode that may work out of the box:

self: super: {
  vscode = super.vscode.overrideAttrs (oldAttrs: rec {
    FONTCONFIG_FILE = super.makeFontsConf { fontDirectories = [ super.fira-code-symbols super.fira-code]; };
  });
}

Thanks for the suggestion. I added the overlay, that seemed to cause emacs to be built from source on my machine. However, when I open emacs I still get the same Fontconfig errors. Note: emacs seems to be working but I’d like to know why I get these errors and how to fix it.

Apologies, I think I misunderstood your error. At first blush I thought you were just missing a particular font.