PHP with custom extension

Hello, first time user of NixOS, long time user of Gentoo/Arch.

I wanted to see if I could use nixos for my workstation, but I am struggling getting the extension pdo_firebird/interbase included into PHP (which we use at my work place).

I tried the following:
php -d extension=pdo_firebird
(no dynamic library in nixos, and there is no packages for it, AFAIK).

I tried also the same with a statically built one on my old arch system, but it depends on a shared library (libfbclient.so.2).

(I also did the same in phpfpm by adding the phpOptions in configuration.nix, but I guess the above is why I don’t see any pdo_firebird loaded in phpinfo)

I had an idea of building the extension on nixos in an nix-env, following https://github.com/FirebirdSQL/php-firebird but phpize is not included in the php package either.

I know that firebird is not an easy PDO, and I also build it manually on Arch Linux to be sure it works correctly in PHP7, but I have no options here as I cannot copy the shared libraries to /usr/lib (I know, it’s tainted ;).

as an update:
I got phpize by using php74.unwrapped.dev instead of php, so that’s a start, and I see that libfbclient.so comes out of the firebird package.

I’ll try to see if I can make a build, and maybe I’ll even learn to make a package in the process :slight_smile:

And I got it working with some hacking, but at least it should be an inspiration for a package:

  1. I made a phpize.nix with pkgs.php74.unwrapped.dev
  2. nix-shell into it
  3. followed the instruction on github (the above link)
$ git clone https://github.com/FirebirdSQL/php-firebird.git
$ cd php-firebird
$ phpize
$ CPPFLAGS=-I/nix/store/shashasha-firebird-3.0.7/include LDDFLAGS=-L/nix/store/shashasha-firebird-3.0.7/lib ./configure
$ make

cp the file from modules/interbase.so to somewhere practical
and link in configuration.nix:

services.phpfpm.phpOptions = '' extension=/location/interbase.so; ''

Now, if I knew how to generalize the shashasha and make a package for future usage, it would also work after an update to firebird next

Try basing it on existing PHP packages. buildPecl should have phpize.