about summary refs log tree commit diff
path: root/pkgs/build-support/php/build-pecl.nix
blob: 16913a85c63deb3c2598623c70e503a49cff532f (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{
  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";
    }
    // lib.filterAttrs (
      attrName: _:
      lib.elem attrName [
        "sha256"
        "hash"
      ]
    ) args
  ),
  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 { };
    };
  }
)