1{
2 lib,
3 stdenv,
4 fetchurl,
5 autoreconfHook,
6 libgpg-error,
7 gnupg,
8 pkg-config,
9 glib,
10 pth,
11 libassuan,
12 which,
13 texinfo,
14 buildPackages,
15 qtbase ? null,
16 # only for passthru.tests
17 libsForQt5,
18 qt6Packages,
19 python3,
20}:
21
22stdenv.mkDerivation rec {
23 pname = "gpgme";
24 version = "1.24.2";
25 pyproject = true;
26
27 outputs = [
28 "out"
29 "dev"
30 "info"
31 ];
32
33 outputBin = "dev"; # gpgme-config; not so sure about gpgme-tool
34
35 src = fetchurl {
36 url = "mirror://gnupg/gpgme/gpgme-${version}.tar.bz2";
37 hash = "sha256-4RsaDjYXd+nlX0igPYkJbiq/CMY9hLcBfP4dzgZjlYE=";
38 };
39
40 patches = [
41 # Fix a test after disallowing compressed signatures in gpg (PR #180336)
42 ./test_t-verify_double-plaintext.patch
43 # Don't use deprecated LFS64 APIs (removed in musl 1.2.4)
44 # https://dev.gnupg.org/D600
45 ./LFS64.patch
46 ];
47
48 nativeBuildInputs = [
49 autoreconfHook
50 gnupg
51 pkg-config
52 texinfo
53 ];
54
55 propagatedBuildInputs = [
56 glib
57 libassuan
58 libgpg-error
59 pth
60 ] ++ lib.optionals (qtbase != null) [ qtbase ];
61
62 nativeCheckInputs = [ which ];
63
64 depsBuildBuild = [ buildPackages.stdenv.cc ];
65
66 dontWrapQtApps = true;
67
68 configureFlags =
69 [
70 "--enable-fixed-path=${gnupg}/bin"
71 "--with-libgpg-error-prefix=${libgpg-error.dev}"
72 "--with-libassuan-prefix=${libassuan.dev}"
73 ]
74 # Tests will try to communicate with gpg-agent instance via a UNIX socket
75 # which has a path length limit. Nix on darwin is using a build directory
76 # that already has quite a long path and the resulting socket path doesn't
77 # fit in the limit. https://github.com/NixOS/nix/pull/1085
78 ++ lib.optionals stdenv.hostPlatform.isDarwin [ "--disable-gpg-test" ];
79
80 env.NIX_CFLAGS_COMPILE = toString (
81 # qgpgme uses Q_ASSERT which retains build inputs at runtime unless
82 # debugging is disabled
83 lib.optional (qtbase != null) "-DQT_NO_DEBUG"
84 # https://www.gnupg.org/documentation/manuals/gpgme/Largefile-Support-_0028LFS_0029.html
85 ++ lib.optional stdenv.hostPlatform.is32bit "-D_FILE_OFFSET_BITS=64"
86 );
87
88 enableParallelBuilding = true;
89
90 # prevent tests from being run during the buildPhase
91 makeFlags = [ "tests=" ];
92
93 doCheck = true;
94
95 checkFlags = [
96 "-C"
97 "tests"
98 ];
99
100 passthru.tests = {
101 python = python3.pkgs.gpgme;
102 qt5 = libsForQt5.qgpgme;
103 qt6 = qt6Packages.qgpgme;
104 };
105
106 meta = with lib; {
107 # fatal error: 'QtCore/qcompare.h' file not found
108 broken = qtbase != null && stdenv.hostPlatform.isDarwin;
109 homepage = "https://gnupg.org/software/gpgme/index.html";
110 changelog = "https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gpgme.git;f=NEWS;hb=gpgme-${version}";
111 description = "Library for making GnuPG easier to use";
112 longDescription = ''
113 GnuPG Made Easy (GPGME) is a library designed to make access to GnuPG
114 easier for applications. It provides a High-Level Crypto API for
115 encryption, decryption, signing, signature verification and key
116 management.
117 '';
118 license = with licenses; [
119 lgpl21Plus
120 gpl3Plus
121 ];
122 platforms = platforms.unix;
123 maintainers = with maintainers; [ dotlambda ];
124 };
125}