1{ buildPecl, lib, gpgme, file, gnupg, php, fetchFromGitHub }:
2
3let
4 version = "1.5.1";
5in buildPecl {
6 inherit version;
7 pname = "gnupg";
8
9 src = fetchFromGitHub {
10 owner = "php-gnupg";
11 repo = "php-gnupg";
12 rev = "gnupg-${version}";
13 fetchSubmodules = true;
14 sha256 = "sha256-kEc0883sYgmAf1mkH0zRjHzUASnZgQvdYE6VzT5X2RI=";
15 };
16
17 buildInputs = [ gpgme ];
18 nativeCheckInputs = [ gnupg ];
19
20 postPhpize = ''
21 substituteInPlace configure \
22 --replace '/usr/bin/file' '${file}/bin/file' \
23 --replace 'SEARCH_PATH="/usr/local /usr /opt"' 'SEARCH_PATH="${gpgme.dev}"'
24 '';
25
26 postConfigure = with lib; ''
27 substituteInPlace Makefile \
28 --replace 'run-tests.php' 'run-tests.php -q --offline'
29 substituteInPlace tests/gnupg_res_init_file_name.phpt \
30 --replace '/usr/bin/gpg' '${gnupg}/bin/gpg' \
31 --replace 'string(12)' 'string(${toString (stringLength "${gnupg}/bin/gpg")})'
32 substituteInPlace tests/gnupg_oo_init_file_name.phpt \
33 --replace '/usr/bin/gpg' '${gnupg}/bin/gpg' \
34 --replace 'string(12)' 'string(${toString (stringLength "${gnupg}/bin/gpg")})'
35 '';
36
37 doCheck = true;
38
39 meta = with lib; {
40 changelog = "https://github.com/php-gnupg/php-gnupg/releases/tag/gnupg-${version}";
41 broken = lib.versionOlder php.version "8.1"; # Broken on PHP older than 8.1.
42 description = "PHP wrapper for GpgME library that provides access to GnuPG";
43 license = licenses.bsd3;
44 homepage = "https://pecl.php.net/package/gnupg";
45 maintainers = with maintainers; [ taikx4 ] ++ teams.php.members;
46 };
47}