about summary refs log tree commit diff
path: root/nixpkgs/pkgs/build-support/php/build-pecl.nix
blob: 389447e066fa2ad0acfd9b370a21fb7db6bd84eb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{ stdenv, lib, php, autoreconfHook, fetchurl, re2c, nix-update-script }:

{ pname
, version
, internalDeps ? [ ]
, peclDeps ? [ ]
, buildInputs ? [ ]
, nativeBuildInputs ? [ ]
, postPhpize ? ""
, makeFlags ? [ ]
, src ? fetchurl {
    url = "https://pecl.php.net/get/${pname}-${version}.tgz";
    inherit (args) sha256;
  }
, passthru ? { }
, ...
}@args:

stdenv.mkDerivation (args // {
  name = "php-${pname}-${version}";
  extensionName = pname;

  inherit src;

  nativeBuildInputs = [ autoreconfHook re2c ] ++ nativeBuildInputs;
  buildInputs = [ php ] ++ peclDeps ++ buildInputs;

  makeFlags = [ "EXTENSION_DIR=$(out)/lib/php/extensions" ] ++ makeFlags;

  autoreconfPhase = ''
    phpize
    ${postPhpize}
    ${lib.concatMapStringsSep "\n"
      (dep: "mkdir -p ext; ln -s ${dep.dev}/include ext/${dep.extensionName}")
      internalDeps}
  '';
  checkPhase = "NO_INTERACTON=yes make test";

  passthru = passthru // {
    # Thes flags were introduced for `nix-update` so that it can update
    # PHP extensions correctly.
    # See the corresponding PR: https://github.com/Mic92/nix-update/pull/123
    isPhpExtension = true;
    updateScript = nix-update-script {};
  };
})