Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

“decimal” extension for PHP 7 #399

Closed
agj opened this issue Feb 8, 2025 · 3 comments
Closed

“decimal” extension for PHP 7 #399

agj opened this issue Feb 8, 2025 · 3 comments

Comments

@agj
Copy link
Contributor

agj commented Feb 8, 2025

Hello, everyone.

With the help of @jtojnar I recently added the “decimal” PHP extension to Nixpkgs. Nixpkgs doesn't have older PHP versions, and I want this extension available for v7.x, so I'd like to submit a PR to this repo adding the necessary stuff.

I followed @jtojnar's advice and tried adding an overlay to it using overrideAttrs. Here's the changes I made.

Adding the JSON extension in internalDeps is what worked for me when I built it using buildPecl for PHP 7.4, but for some reason it's not working here.

Here's the flake I'm using to test things out:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
    phps.url = "github:agj/nix-phps?ref=extensions/fix-decimal-php7";
    phps.inputs.nixpkgs.follows = "nixpkgs";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs =
    { self, nixpkgs, phps, flake-utils }:
    flake-utils.lib.eachDefaultSystem (
      system:
      let
        pkgs = import nixpkgs { system = system; };
        phps-pkgs = phps.packages.${system};
      in
      {
        devShell = pkgs.mkShell {
          buildInputs = [
            (phps-pkgs.php74.buildEnv { extensions = { all, enabled }: enabled ++ [ all.decimal ]; })
          ];
        };
      }
    );
}

When building I get the same error I originally got due to the JSON extension not being present:

error: builder for '/nix/store/w8v3b0v89g9byzpm254ai1msp35fjqjm-php-decimal-1.5.0.drv' failed with exit code 2;
       last 25 log lines:
       > checking whether to build static libraries... no
       >
       > creating libtool
       > appending configuration tag "CXX" to libtool
       > checking whether the clang++ linker (ld) supports shared libraries... no
       > checking for clang++ option to produce PIC...
       > checking if clang++ static flag  works... yes
       > checking if clang++ supports -c -o file.o... yes
       > checking whether the clang++ linker (ld) supports shared libraries... no
       > checking dynamic linker characteristics... darwin21.6.0 dyld
       > (cached) (cached) checking how to hardcode library paths into programs... immediate
       > configure: patching config.h.in
       > configure: creating ./config.status
       > config.status: creating config.h
       > configurePhase completed in 48 seconds
       > Running phase: buildPhase
       > build flags: SHELL=/nix/store/69mz5vmvbjxdxksqj85fbhwfhbmybcgj-bash-5.2p37/bin/bash EXTENSION_DIR=\$\(out\)/lib/php/extensions
       > /nix/store/69mz5vmvbjxdxksqj85fbhwfhbmybcgj-bash-5.2p37/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/f5shd5f43wscrp98mk0ldr7mhi8fi8kw-php-7.4.33-dev/include/php -I/nix/store/f5shd5f43wscrp98mk0ldr7mhi8fi8kw-php-7.4.33-dev/include/php/main -I/nix/store/f5shd5f43wscrp98mk0ldr7mhi8fi8kw-php-7.4.33-dev/include/php/TSRM -I/nix/store/f5shd5f43wscrp98mk0ldr7mhi8fi8kw-php-7.4.33-dev/include/php/Zend -I/nix/store/f5shd5f43wscrp98mk0ldr7mhi8fi8kw-php-7.4.33-dev/include/php/ext -I/nix/store/f5shd5f43wscrp98mk0ldr7mhi8fi8kw-php-7.4.33-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/f5shd5f43wscrp98mk0ldr7mhi8fi8kw-php-7.4.33-dev/include/php -I/nix/store/f5shd5f43wscrp98mk0ldr7mhi8fi8kw-php-7.4.33-dev/include/php/main -I/nix/store/f5shd5f43wscrp98mk0ldr7mhi8fi8kw-php-7.4.33-dev/include/php/TSRM -I/nix/store/f5shd5f43wscrp98mk0ldr7mhi8fi8kw-php-7.4.33-dev/include/php/Zend -I/nix/store/f5shd5f43wscrp98mk0ldr7mhi8fi8kw-php-7.4.33-dev/include/php/ext -I/nix/store/f5shd5f43wscrp98mk0ldr7mhi8fi8kw-php-7.4.33-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:
       > /private/tmp/nix-build-php-decimal-1.5.0.drv-0/decimal-1.5.0/php_decimal.h:48:10: fatal error: 'ext/json/php_json.h' file not found
       >    48 | #include "ext/json/php_json.h"
       >       |          ^~~~~~~~~~~~~~~~~~~~~
       >
       For full logs, run 'nix log /nix/store/w8v3b0v89g9byzpm254ai1msp35fjqjm-php-decimal-1.5.0.drv'.
error: 1 dependencies of derivation '/nix/store/yq5x4pmvnjg3b64s0pl0w9figa24hscv-php-extra-init-7.4.33.ini.drv' failed to build
error: 1 dependencies of derivation '/nix/store/rry78aswgl4x5yx6mhvl8y1i5byfy4d1-php-with-extensions-7.4.33.drv' failed to build
error: 1 dependencies of derivation '/nix/store/7fa2r4wxdr3c0rdbavx2r4n50a4mv7sc-nix-shell-env.drv' failed to build

Could I get some help getting this to work and eventually submitting this as a PR? Thank you. 🙏

@jtojnar
Copy link
Member

jtojnar commented Feb 8, 2025

internalDeps is not currently overrideable so you need to append linkInternalDeps to preConfigure, the see e.g. couchbase

@agj
Copy link
Contributor Author

agj commented Feb 8, 2025

Thanks again, @jtojnar! I now understand what you meant when you linked me to that expression. And, it worked! I'll prepare a PR for this then. 🙏

@agj
Copy link
Contributor Author

agj commented Feb 8, 2025

PR #400 submitted!

@agj agj closed this as completed Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants