PHP in Nixpkgs applies some patches so your overridden src
needs to be compatible with that or the patch will fail to apply as you see:
Also the php
package expects source of PHP project such as
you are passing it source for Nixpkgs:
Also note that just overriding the src
and patches
likely will not be sufficient. For example, we have a whole project dedicated just for providing such overlays for PHP, and it requires many other changes of both php
itself and related packages.
You could try to obtain the package from an older snapshot of Nixpkgs (as found by something like Searching and installing old versions of Nix packages or Nixhub.io | Search Historical Versions of Nix Packages) but that might introduce breakages (e.g. loading mod_php
from ancient Nixpkgs might have incompatible ABI with Apache from current Nixpkgs) and security issues (Nixpkgs snapshots will obviously not receive any updates).