Libc version is different before and after nix-shell -p

This is a known limitation, you need the newest libc you’re going to use to load first. This means using a driver built against a lower libc (e.g. via nixGL), or pre-loading the newer libc (via LD_PRELOAD), or something of the sort.

Cf. GitHub - nix-community/nixGL: A wrapper tool for nix OpenGL application [maintainer=@guibou], Build against an older libc, keep the newest in the runtime closure · Issue #303405 · NixOS/nixpkgs · GitHub, Help understanding the libGL ABI problem and possible solutions