Hello, everyone. I’m trying to get a legacy system’s development setup away from containers and working under Nix. This system uses PHP 7.1, but the closest I’ve been able to get working is 7.4. I’m using Devenv, although it’s not prepared for PHP stuff this old, so I’m having to build extensions myself and stuff. I have to say, I’m not an expert in either PHP or Nix, so bear with me…
Most of the extensions were already available, but some I couldn’t find. So I had luck building mcrypt
using buildPecl
, like so:
php-mcrypt = pkgs-php.php74.buildPecl {
pname = "mcrypt";
version = "1.0.7";
sha256 = "Euovu/Li7755ChISH3e/CWyLhM74HQIWvsANVuW63vQ=";
buildInputs = [
pkgs.libmcrypt
pkgs.mcrypt
pkgs.gawk
pkgs.pkg-config
];
configureFlags = ["--with-mcrypt=${pkgs.libmcrypt}"];
};
Where pkgs-php
is an old version of Nixpkgs that has PHP 7.4, as an input. I’m sure a lot of those buildInputs
aren’t even needed.
I got stuck, however, getting the decimal
extension to work. This is how far I got:
php-decimal = pkgs-php.php74.buildPecl {
pname = "decimal";
version = "1.5.0";
sha256 = "it8w8hOLYwtCZoDYhaP5k5TD/pQLtj37K2lSESF80ok=";
buildInputs = [
pkgs.mpdecimal
];
configureFlags = ["--with-libmpdec-path=${pkgs.mpdecimal}"];
};
Figuring out the flag to specify mpdecimal
took me way, way too long. But now I’m getting this error about some php_json.h
file.
> build flags: SHELL=/nix/store/8f6h1lp9i8s0pd31n220k9zh1ksb13ln-bash-5.1-p16/bin/bash EXTENSION_DIR=\$\(out\)/lib/php/extensions
> /nix/store/8f6h1lp9i8s0pd31n220k9zh1ksb13ln-bash-5.1-p16/bin/bash /private/tmp/nix-build-php-decimal-1.5.0.drv-0/decimal-1.5.0/libtool --mode=compile clang -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/private/tmp/nix-build-php-decimal-1.5.0.drv-0/decimal-1.5.0 -DPHP_ATOM_INC -I/private/tmp/nix-build-php-decimal-1.5.0.drv-0/decimal-1.5.0/include -I/private/tmp/nix-build-php-decimal-1.5.0.drv-0/decimal-1.5.0/main -I/private/tmp/nix-build-php-decimal-1.5.0.drv-0/decimal-1.5.0 -I/nix/store/6n4kzn2ai0d8wfx0vkld6x01wwr8lslx-php-7.4.29-dev/include/php -I/nix/store/6n4kzn2ai0d8wfx0vkld6x01wwr8lslx-php-7.4.29-dev/include/php/main -I/nix/store/6n4kzn2ai0d8wfx0vkld6x01wwr8lslx-php-7.4.29-dev/include/php/TSRM -I/nix/store/6n4kzn2ai0d8wfx0vkld6x01wwr8lslx-php-7.4.29-dev/include/php/Zend -I/nix/store/6n4kzn2ai0d8wfx0vkld6x01wwr8lslx-php-7.4.29-dev/include/php/ext -I/nix/store/6n4kzn2ai0d8wfx0vkld6x01wwr8lslx-php-7.4.29-dev/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /private/tmp/nix-build-php-decimal-1.5.0.drv-0/decimal-1.5.0/php_decimal.c -o php_decimal.lo
> mkdir .libs
> clang -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/private/tmp/nix-build-php-decimal-1.5.0.drv-0/decimal-1.5.0 -DPHP_ATOM_INC -I/private/tmp/nix-build-php-decimal-1.5.0.drv-0/decimal-1.5.0/include -I/private/tmp/nix-build-php-decimal-1.5.0.drv-0/decimal-1.5.0/main -I/private/tmp/nix-build-php-decimal-1.5.0.drv-0/decimal-1.5.0 -I/nix/store/6n4kzn2ai0d8wfx0vkld6x01wwr8lslx-php-7.4.29-dev/include/php -I/nix/store/6n4kzn2ai0d8wfx0vkld6x01wwr8lslx-php-7.4.29-dev/include/php/main -I/nix/store/6n4kzn2ai0d8wfx0vkld6x01wwr8lslx-php-7.4.29-dev/include/php/TSRM -I/nix/store/6n4kzn2ai0d8wfx0vkld6x01wwr8lslx-php-7.4.29-dev/include/php/Zend -I/nix/store/6n4kzn2ai0d8wfx0vkld6x01wwr8lslx-php-7.4.29-dev/include/php/ext -I/nix/store/6n4kzn2ai0d8wfx0vkld6x01wwr8lslx-php-7.4.29-dev/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /private/tmp/nix-build-php-decimal-1.5.0.drv-0/decimal-1.5.0/php_decimal.c -fno-common -DPIC -o .libs/php_decimal.o
> In file included from /private/tmp/nix-build-php-decimal-1.5.0.drv-0/decimal-1.5.0/php_decimal.c:27:
> ./php_decimal.h:48:10: fatal error: 'ext/json/php_json.h' file not found
> #include "ext/json/php_json.h"
> ^~~~~~~~~~~~~~~~~~~~~
> 1 error generated.
My guess is that this version of PHP doesn’t include the JSON extension. I tried building with PHP 8.1 and sure enough it built, but now it isn’t compatible with the PHP 7.4 that I’m trying to use it on.
If it sounds like I don’t know that I’m doing, it’s because I don’t. Appreciate any guidance at all.