Yet another uv/matplotlib issue

Hello! I’m running NixOS on package channel 25.05. Here is my current configuration.nix (I put everything just to be sure I don’t miss anything out):

{ config, pkgs, ... }:
{
  imports = [./hardware-configuration.nix];

  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  networking.hostName = "nixos"; # Define your hostname.
  networking.networkmanager.enable = true;

  time.timeZone = "Europe/Paris";
  i18n.defaultLocale = "fr_FR.UTF-8";
  i18n.extraLocaleSettings = {
    LC_ADDRESS = "fr_FR.UTF-8";
    LC_IDENTIFICATION = "fr_FR.UTF-8";
    LC_MEASUREMENT = "fr_FR.UTF-8";
    LC_MONETARY = "fr_FR.UTF-8";
    LC_NAME = "fr_FR.UTF-8";
    LC_NUMERIC = "fr_FR.UTF-8";
    LC_PAPER = "fr_FR.UTF-8";
    LC_TELEPHONE = "fr_FR.UTF-8";
    LC_TIME = "fr_FR.UTF-8";
  };

  services.xserver.enable = true;

  services.displayManager.sddm.enable = true;
  services.desktopManager.plasma6.enable = true;
  services.xserver.xkb = {
    layout = "fr";
    variant = "azerty";
  };
  console.keyMap = "fr";

  services.printing.enable = true;

  services.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
  };

  users.users.myself = {
    isNormalUser = true;
    description = "My Name";
    extraGroups = [ "networkmanager" "wheel" ];
    packages = with pkgs; [
      kdePackages.kate
      zotero
      yt-dlg
    ];
  };

  programs.steam = {
    enable = true;
    remotePlay.openFirewall = true;
    dedicatedServer.openFirewall = true;
    localNetworkGameTransfers.openFirewall = true;
  };

  programs.firefox.enable = true;

  services.flatpak.enable = true;
  systemd.services.flatpak-repo = {
    wantedBy = [ "multi-user.target" ];
    path = [ pkgs.flatpak ];
    script = ''
      flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
    '';
  };

  nixpkgs.config.allowUnfree = true;

  environment.systemPackages = with pkgs; [
    vim
    wget
    ripgrep
    ripgrep-all
    fd
    nix-ld

    darkly
    thunderbird
  ];

  programs.nix-ld.enable = true;
  programs.nix-ld.libraries = with pkgs; [
    libGL
    fontconfig
    libxkbcommon
    wayland
    xorg.libX11
    xorg.libxcb
    xorg.xcbutilwm
    xorg.xcbutilimage
    xorg.xcbutilkeysyms
    xorg.xcbutilrenderutil
    xcb-util-cursor
    freetype
    dbus
    glib
    glibc
    zlib
    zstd
    stdenv.cc.cc 
    file
    curl
    openssl
    attr
    libssh
    bzip2
    libxml2
    acl
    libsodium
    util-linux
    xz
    systemd
  ];

  system.stateVersion = "25.05"; # Did you read the comment?
}

I did put quite a few libs under nix-ld. Though, if I enter nix-shell -p uv, and that I run LD_LIBRARY_PATH=$NIX_LD_LIBRARY_PATH uv run python in a project equipped with numpy, matplotlib and PySide6, the following code just crashed without any opened window or error message:

import matplotlib.pyplot as plt
import numpy as np
import matplotlib
matplotlib.use("qtagg")

x = np.linspace(0, np.pi, 150)
plt.plot(x, np.sin(x))
plt.show() # crash

Any ideas?

Don’t use the Qt backend, it’s essentially broken as packaged in Nixpkgs. See: pyplot not working in ipython · Issue #80147 · NixOS/nixpkgs · GitHub

Thanks. Took me a bit to have the TkAgg working but now it’s alright.