Thank you, what a wonderful summary, It would be best to remove the need to do the sed at all.
I’ve reviewed Revert "Unwrap python scripts when building an environment" by SuperSandro2000 · Pull Request #302385 · NixOS/nixpkgs · GitHub and I’m going go try to identify and fix the actually impacted packages.