X11 Font Load Failure

Issue

When running the X-Plane 12 Installer (patched) on NixOS with Gnome on Wayland, the following error occurs:

Couldn't load font -*-*-medium-r-normal--0-120-*-*-p-0-iso8859-1

shortly followed by

Segmentation fault (core dumped)

This does not happen with Gnome on Xorg. Neither does it with the X-Plane 11 Installer on both Wayland and Xorg.
The derivation is installed via the nix home manager.

Suspected Reason

I suspect this is likely to be an issue with some of the following points:

  • xwayland (Xorg-Wayland compatibility layer) configuration issues,
  • xfs (X Font Server) or another service that is only started when on X11,
  • fontconfig or another faulty configuration that is used for font loading or
  • libraries or resources that are not visible to the xp12-installer when it is running (maybe due to lfs references that no longer exist under nixos - but somehow work on X11).
    It appears that the font loading is done using a glibc library.

Installer Derivation

# X-Plane 12 Installer
# https://www.x-plane.com/kb/installer-versions/
{
  pkgs ? import <nixpkgs> { }
}: pkgs.stdenv.mkDerivation rec {
  pname = "x-plane.12-installer";
  version = "503";

  meta = with pkgs.lib; {
    description = "A flight simulator built by pilots, for everyone - Binary Installer";
    homepage = "https://www.x-plane.com/";
    changelog = "https://www.x-plane.com/knowledgebase_category/release-notes/";
    downloadPage = "https://www.x-plane.com/desktop/try-it/";
    license = licenses.unfree;
    mainProgram = "xp12-installer";
    maintainers = with maintainers; [ ]; # TODO: Set Maintainer
    platforms = platforms.linux;
  };

  src = pkgs.fetchurl {
    url = "https://lookup.x-plane.com/_lookup_12_/download/X-Plane12InstallerLinux.zip";
    sha256 = "0q5v89fskfcag53nnzmzpapmzs11z005gwl3d42c68jhc15z9pvn";
  };

  nativeBuildInputs = with pkgs; [
    autoPatchelfHook
    imagemagick
    unzip
  ];

  buildInputs = with pkgs; [
    atk
    cairo
    gdk-pixbuf
    glib
    glibc
    gtk3
    libgcc
    libGL
    libGLU
    pango
    xorg.libXcursor
    xorg.libXinerama
    xorg.libXrandr
  ];

  unpackPhase = ''
    mkdir -p $TMP;
    cd $TMP;
    unzip $src;
  '';

  buildPhase = let
    icon = pkgs.fetchurl {
      url = "https://www.x-plane.com/wp-content/uploads/2022/09/SocialXP3.png";
      sha256 = "1bfnb8n0n9r4cb1py2qspcs3jhbr1hbq7xnf08nmfyqh4wgvd3qs";
    };
  in ''
    # Resize icon
    convert ${icon} -scale 512x512 $TMP/icon.png
  '';

  installPhase = let
    launcher = pkgs.makeDesktopItem {
      name = pname;
      exec = "xp12-installer";
      desktopName = "X-Plane 12";
      genericName = "X-Plane 12 Installer";
      categories = [ ];
      icon = "xp12-installer";
    };

    icon = pkgs.fetchurl {
      url = "https://www.x-plane.com/wp-content/uploads/2022/09/SocialXP3.png";
      sha256 = "1bfnb8n0n9r4cb1py2qspcs3jhbr1hbq7xnf08nmfyqh4wgvd3qs";
    };
  in ''
    # Executable
    mkdir -p $out/bin;
    cp $TMP/X-Plane\ 12\ Installer\ Linux $out/bin/xp12-installer;

    # Launcher
    mkdir -p $out/share/applications;
    cp ${launcher}/share/applications/*.desktop $out/share/applications/;

    # Icon
    mkdir -p $out/share/icons/hicolor/512x512/apps
    cp $TMP/icon.png $out/share/icons/hicolor/512x512/apps/xp12-installer.png
  '';
}

Nix Home Configuration

# Home Configuration
{ config, pkgs, ... }: {
  nixpkgs.config.allowUnfree = true;

  # Build Configuration
  home = {
    stateVersion = "25.05";
  };

  # User Configuration
  home = {
    username = "user";
    homeDirectory = "/home/user";
  };

  # Other
  home = {
    file = {};
    sessionVariables = {};
  };

  home = {
    packages = with pkgs; [
      bat
      binutils
      discord
      eza
      fd
      fzf
      ghostty
      gimp3
      git
      github-desktop
      gnutar
      google-chrome
      htop
      inkscape
      jdk24
      jetbrains.idea-community
      jetbrains.pycharm-community
      kicad
      maven
      modrinth-app
      orca-slicer
      python314
      quartus-prime-lite
      rename
      ripgrep
      spotify
      texliveFull
      unzip
      vlc
      xclip
      zip

      (callPackage ./Deriv/x-plane.wed-bin.nix { pkgs = pkgs; })
      (callPackage ./Deriv/x-plane.11-installer.nix { pkgs = pkgs; })
      (callPackage ./Deriv/x-plane.12-installer.nix { pkgs = pkgs; })
    ];
  };

  programs = {
    home-manager.enable = true;

    bash = {
      enable = true;
      bashrcExtra = ''...'';
    };

    neovim = {
      enable = true;
      viAlias = true;
      vimAlias = true;
      extraConfig = ''...'';
    };
  };
}

NixOs Configuration

# System-Wide General Configuration
{ config, lib, pkgs, ... }: {
  imports = [ ./hardware-configuration.nix ];

  # Build Configuration
  system.stateVersion = "25.05";

  # General Settings
  nixpkgs.config.allowUnfree = true;

  hardware = {
    enableAllFirmware = true;
    graphics.enable = true;
    graphics.enable32Bit = true;
  };

  # Network Settings
  networking = {
    hostName = "host";
    networkmanager.enable = true;
    firewall.enable = false;
    # wireless.enable = true;
  };

  # Localisation Settings
  i18n.defaultLocale = "en_US.UTF-8";
  time.timeZone = "Europe/Amsterdam";

  console = {
    font = null;
    useXkbConfig = true;
  };

  # Services
  services = { 
    libinput.enable = true;
    printing.enable = true;
    # openssh.enable = true;

    # Audio Settings
    pipewire = {
      enable = true;
      jack.enable = true;
      audio.enable = true;
      pulse.enable = true;
      alsa = {
        enable = true;
        support32Bit = true;
      };
    };

    xserver = {
      # Window Manager Settings
      enable = true;
      displayManager.gdm.enable = true;
      desktopManager.gnome.enable = true;

      # Keyboard Settings
      xkb = {
        layout = "de";
        variant = "nodeadkeys";
        options = "caps:none,eurosign:e";
      };
    };
  };

  # Users
  users.users.user = {
    isNormalUser = true;
    extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
    hashedPassword = "xxx";
    packages = with pkgs; [];
  };

  # Experimental Features
  nix.settings.experimental-features = [ "nix-command" "flakes" ];

  # System-Wide Software
  environment.systemPackages = with pkgs; [
    brave
    wget
    jetbrains-mono
  ];

  programs = {
    neovim.enable = true;
    git.enable = true;
    steam.enable = true;
  };
}

So as it appears, the X-Plane 12 Installer uses outdated legacy X11 core fonts. This requires the necessary fonts to be added to the legacy X11 font path, which can be queried by running xset q for the path and xlsfonts for loaded fonts.

This font path is loaded and set when running Gnome on Xorg. xset q then returns a font path that contains several references to the nix store, in addition to the default built-ins entry. xlsfonts output is also fairly extensive, listing all loaded fonts.

However, when running Gnome on Wayland, xset q only returns the built-ins as font path. xlsfonts only lists very few fonts, none of which match the requested XLFD (X Logical Font Description).

I have attempted following potential fixes to no avail:

  • adding fonts.fontDir.enable = true to /etc/configuration.nix which generates a font library at /run/current-system/sw/share/X11/fonts,
  • manually setting programs.xwayland.defaultFontPath to the generated font library and
  • modifying the Xwayland configuration to fix legacy font loading.

Though it seems that Xwayland does not support legacy X11 core fonts at all.

Is there any way to

  • enable legacy X11 core font support under Wayland or
  • set the X11 font path under Wayland?