php: expose mkExtension

launchpad/nixpkgs/master
Aaron Andersen 3 years ago
parent 2db14a9cb5
commit 485d0fc973
  1. 2
      pkgs/development/interpreters/php/generic.nix
  2. 133
      pkgs/top-level/php-packages.nix

@ -133,7 +133,7 @@ let
unwrapped = php;
# Select the right php tests for the php version
tests = nixosTests."php${lib.strings.replaceStrings [ "." ] [ "" ] (lib.versions.majorMinor php.version)}";
inherit (php-packages) extensions buildPecl;
inherit (php-packages) extensions buildPecl mkExtension;
packages = php-packages.tools;
meta = php.meta // {
outputsToInstall = [ "out" ];

@ -59,6 +59,73 @@ lib.makeScope pkgs.newScope (self: with self; {
pname = "php-${pname}";
});
# Function to build an extension which is shipped as part of the php
# source, based on the php version.
#
# Name passed is the name of the extension and is automatically used
# to add the configureFlag "--enable-${name}", which can be overriden.
#
# Build inputs is used for extra deps that may be needed. And zendExtension
# will mark the extension as a zend extension or not.
mkExtension =
{ name
, configureFlags ? [ "--enable-${name}" ]
, internalDeps ? [ ]
, postPhpize ? ""
, buildInputs ? [ ]
, zendExtension ? false
, doCheck ? true
, ...
}@args: stdenv.mkDerivation ((builtins.removeAttrs args [ "name" ]) // {
pname = "php-${name}";
extensionName = name;
inherit (php.unwrapped) version src;
sourceRoot = "php-${php.version}/ext/${name}";
enableParallelBuilding = true;
nativeBuildInputs = [ php.unwrapped autoconf pkg-config re2c ];
inherit configureFlags internalDeps buildInputs
zendExtension doCheck;
prePatch = "pushd ../..";
postPatch = "popd";
preConfigure = ''
nullglobRestore=$(shopt -p nullglob)
shopt -u nullglob # To make ?-globbing work
# Some extensions have a config0.m4 or config9.m4
if [ -f config?.m4 ]; then
mv config?.m4 config.m4
fi
$nullglobRestore
phpize
${postPhpize}
${lib.concatMapStringsSep "\n"
(dep: "mkdir -p ext; ln -s ${dep.dev}/include ext/${dep.extensionName}")
internalDeps}
'';
checkPhase = "runHook preCheck; NO_INTERACTON=yes make test; runHook postCheck";
outputs = [ "out" "dev" ];
installPhase = ''
mkdir -p $out/lib/php/extensions
cp modules/${name}.so $out/lib/php/extensions/${name}.so
mkdir -p $dev/include
${rsync}/bin/rsync -r --filter="+ */" \
--filter="+ *.h" \
--filter="- *" \
--prune-empty-dirs \
. $dev/include/
'';
meta = {
description = "PHP upstream extension: ${name}";
inherit (php.meta) maintainers homepage license;
};
});
php = phpPackage;
# This is a set of interactive tools based on PHP.
@ -171,72 +238,6 @@ lib.makeScope pkgs.newScope (self: with self; {
yaml = callPackage ../development/php-packages/yaml { };
} // (
let
# Function to build a single php extension based on the php version.
#
# Name passed is the name of the extension and is automatically used
# to add the configureFlag "--enable-${name}", which can be overriden.
#
# Build inputs is used for extra deps that may be needed. And zendExtension
# will mark the extension as a zend extension or not.
mkExtension =
{ name
, configureFlags ? [ "--enable-${name}" ]
, internalDeps ? [ ]
, postPhpize ? ""
, buildInputs ? [ ]
, zendExtension ? false
, doCheck ? true
, ...
}@args: stdenv.mkDerivation ((builtins.removeAttrs args [ "name" ]) // {
pname = "php-${name}";
extensionName = name;
inherit (php.unwrapped) version src;
sourceRoot = "php-${php.version}/ext/${name}";
enableParallelBuilding = true;
nativeBuildInputs = [ php.unwrapped autoconf pkg-config re2c ];
inherit configureFlags internalDeps buildInputs
zendExtension doCheck;
prePatch = "pushd ../..";
postPatch = "popd";
preConfigure = ''
nullglobRestore=$(shopt -p nullglob)
shopt -u nullglob # To make ?-globbing work
# Some extensions have a config0.m4 or config9.m4
if [ -f config?.m4 ]; then
mv config?.m4 config.m4
fi
$nullglobRestore
phpize
${postPhpize}
${lib.concatMapStringsSep "\n"
(dep: "mkdir -p ext; ln -s ${dep.dev}/include ext/${dep.extensionName}")
internalDeps}
'';
checkPhase = "runHook preCheck; NO_INTERACTON=yes make test; runHook postCheck";
outputs = [ "out" "dev" ];
installPhase = ''
mkdir -p $out/lib/php/extensions
cp modules/${name}.so $out/lib/php/extensions/${name}.so
mkdir -p $dev/include
${rsync}/bin/rsync -r --filter="+ */" \
--filter="+ *.h" \
--filter="- *" \
--prune-empty-dirs \
. $dev/include/
'';
meta = {
description = "PHP upstream extension: ${name}";
inherit (php.meta) maintainers homepage license;
};
});
# This list contains build instructions for different modules that one may
# want to build.
#

Loading…
Cancel
Save