7 , enableCapabilities ? false, libcap
15 assert enableCapabilities -> stdenv.isLinux;
17 stdenv.mkDerivation rec {
22 url = "mirror://gnupg/libgcrypt/${pname}-${version}.tar.bz2";
23 hash = "sha256-O5wCoAS2jCVq3ZlwHeALODrMzPNxd+DWxYKJZkzODAM=";
26 patches = lib.optionals (!stdenv.isLinux) [ # not everywhere to avoid rebuild for now
28 name = "getrandom-conditionalize.patch";
29 url = "https://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgcrypt.git;a=commitdiff_plain;h=d41177937cea4aa1e9042ebcd195a349c40e8071";
30 hash = "sha256-CgQjNtC1qLe5LicIc8rESc6Z1u4fk7ErMUVcG/2G9gM=";
34 outputs = [ "out" "dev" "info" ];
37 # The CPU Jitter random number generator must not be compiled with
38 # optimizations and the optimize -O0 pragma only works for gcc.
39 # The build enables -O2 by default for everything else.
40 hardeningDisable = lib.optional stdenv.cc.isClang "fortify";
42 depsBuildBuild = [ buildPackages.stdenv.cc ];
44 buildInputs = [ libgpg-error ]
45 ++ lib.optional stdenv.isDarwin gettext
46 ++ lib.optional enableCapabilities libcap;
50 configureFlags = [ "--with-libgpg-error-prefix=${libgpg-error.dev}" ]
51 ++ lib.optional (stdenv.hostPlatform.isMusl || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)) "--disable-asm"; # for darwin see https://dev.gnupg.org/T5157
53 # Necessary to generate correct assembly when compiling for aarch32 on
55 configurePlatforms = [ "host" "build" ];
59 -e 's/NOEXECSTACK_FLAGS=$/NOEXECSTACK_FLAGS="-Wa,--noexecstack"/'
62 # Make sure libraries are correct for .pc and .la files
63 # Also make sure includes are fixed for callers who don't use libgpgcrypt-config
65 sed -i 's,#include <gpg-error.h>,#include "${libgpg-error.dev}/include/gpg-error.h",g' "$dev/include/gcrypt.h"
66 '' + lib.optionalString enableCapabilities ''
67 sed -i 's,\(-lcap\),-L${libcap.lib}/lib \1,' $out/lib/libgcrypt.la
70 # TODO: figure out why this is even necessary and why the missing dylib only crashes
71 # random instead of every test
72 preCheck = lib.optionalString stdenv.isDarwin ''
74 cp src/.libs/libgcrypt.20.dylib $out/lib
80 inherit gnupg libotr rsyslog;
84 homepage = "https://www.gnu.org/software/libgcrypt/";
85 changelog = "https://git.gnupg.org/cgi-bin/gitweb.cgi?p=${pname}.git;a=blob;f=NEWS;hb=refs/tags/${pname}-${version}";
86 description = "General-purpose cryptographic library";
87 license = licenses.lgpl2Plus;
88 platforms = platforms.all;
89 maintainers = with maintainers; [ vrthra ];