How to add a custom php extension


I’ve been successfully running different versions of PHP alongside eachother, using a forked version of the nixpkgs repo. The reason being I felt more comfortable adjusting the existing repo instead of creating the clever overlays needed to achieve this. Since version 19.03 this is now possible by default thanks to @wmertens and others.

Currently I’m looking to move away from my forked nixpkgs version and want to try overlays, but I’m failing the in-depth knowledge on how to achieve this. PHP extensions (eg. php72Packages.composer) seem not easy to be extended. Can anyone help me with this? How would I overlay / extend / adjust a config to have a custom php extension added, adding a --with-xxx build option to php itself?

Kind regards,


1 Like

Hey @4levels did you found a way to create derivation for a custom php extension?

I am trying to configure dev environment for an old php project and the only repo providing php5.6 is this one GitHub - fossar/nix-phps: Repository of Nix expressions for old PHP versions but they do not include Mcrypt extension so I am planning to build it on my own. So I am looking for some example on how to do that.