about summary refs log tree commit diff
path: root/pkgs/development/php-packages/gnupg/default.nix
blob: 1341ca2d16962cc916e6bc20624c854a96839c41 (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
{ buildPecl, lib, gpgme, file, gnupg, php, fetchFromGitHub }:

let
  version = "1.5.1";
in buildPecl {
  inherit version;
  pname = "gnupg";

  src = fetchFromGitHub {
    owner = "php-gnupg";
    repo = "php-gnupg";
    rev = "gnupg-${version}";
    fetchSubmodules = true;
    sha256 = "sha256-kEc0883sYgmAf1mkH0zRjHzUASnZgQvdYE6VzT5X2RI=";
  };

  buildInputs = [ gpgme ];
  nativeCheckInputs = [ gnupg ];

  postPhpize = ''
    substituteInPlace configure \
      --replace '/usr/bin/file' '${file}/bin/file' \
      --replace 'SEARCH_PATH="/usr/local /usr /opt"' 'SEARCH_PATH="${gpgme.dev}"'
  '';

  postConfigure = with lib; ''
    substituteInPlace Makefile \
      --replace 'run-tests.php' 'run-tests.php -q --offline'
    substituteInPlace tests/gnupg_res_init_file_name.phpt \
      --replace '/usr/bin/gpg' '${gnupg}/bin/gpg' \
      --replace 'string(12)' 'string(${toString (stringLength "${gnupg}/bin/gpg")})'
    substituteInPlace tests/gnupg_oo_init_file_name.phpt \
      --replace '/usr/bin/gpg' '${gnupg}/bin/gpg' \
      --replace 'string(12)' 'string(${toString (stringLength "${gnupg}/bin/gpg")})'
  '';

  doCheck = true;

  meta = with lib; {
    changelog = "https://github.com/php-gnupg/php-gnupg/releases/tag/gnupg-${version}";
    broken = lib.versionOlder php.version "8.1"; # Broken on PHP older than 8.1.
    description = "PHP wrapper for GpgME library that provides access to GnuPG";
    license = licenses.bsd3;
    homepage = "https://pecl.php.net/package/gnupg";
    maintainers = with maintainers; [ taikx4 ] ++ teams.php.members;
  };
}