Python overlay randomly stopped working

This python overlay was working fine:

  nixpkgs.overlays = [
    inputs.hyprpanel.overlay

    (self: super: rec {
      pythonldlibpath = lib.makeLibraryPath (with super; [
        zlib zstd stdenv.cc.cc curl openssl attr libssh bzip2 libxml2 acl libsodium util-linux xz systemd
      ]);
      # here we are overriding python program to add LD_LIBRARY_PATH to it's env
      python-overlay = super.stdenv.mkDerivation {
        name = "python";
        buildInputs = [ super.makeWrapper ];
        src = super.python312.withPackages(ps: with ps; [ tkinter ]);
        installPhase = ''
          mkdir -p $out/bin
          cp -r $src/* $out/
          wrapProgram $out/bin/python3 --set LD_LIBRARY_PATH ${pythonldlibpath}
          wrapProgram $out/bin/python3.12 --set LD_LIBRARY_PATH ${pythonldlibpath}
        '';
      };
    })
  ];

  environment.systemPackages = with pkgs; [
    python-overlay
  ];

Then a week or two ago, it stopped working and started giving me this error again:

 ImportError: libz.so.1: cannot open shared object file: No such file or directory

Any suggestions on how to root cause what changed?

Apparently when I add the “withPackages” to the line above, it breaks the part in the installPhase where it sets the LD_LIBRARY_PATH.

Any suggestions?