Python matplotlib can't show plot in NixOS

The above solutions did never really work out for me, and I always return to this flake I got inspired from somewhere:

{
  inputs = {
    utils.url = "github:numtide/flake-utils";
  };
  outputs = { self, nixpkgs, utils }: utils.lib.eachDefaultSystem (system:
    let
      pkgs = nixpkgs.legacyPackages.${system};
      pythonEnv = pkgs.python313.withPackages ( ps: with ps; [
      ] );
    in
      {
        devShell = pkgs.mkShell {
          buildInputs = with pkgs; [
            uv
            pythonEnv
            
            glib
            zlib
            libGL
            stdenv.cc.cc.lib
            libsForQt5.wrapQtAppsHook
            (python313Packages.matplotlib.override {
              enableQt = true;
            })
          ];

          LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath [
            pkgs.stdenv.cc.cc.lib
            pkgs.zlib
            pkgs.libGL
            pkgs.glib.out
          ]}:$LD_LIBRARY_PATH";
          
          UV_PYTHON="${pythonEnv}/bin/python";
          UV_PYTHON_PREFERENCE = "only-system";
          # shellHook = ''
          # '' ;
        };
      }
  );

}

This gives an environment with uv (tested with poetry too) that has working SSL, as able to import numpy, pandas and the other usual suspects, and can correctly show the Qt matplitlib windows.