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