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