linux_xanmod: 5.11.14 -> 5.11.15
[NixPkgs.git] / pkgs / development / libraries / libgcrypt / default.nix
blob6b761d2170c320027b83822f55c1857d2ce57045
1 { lib, stdenv, fetchurl, gettext, libgpgerror, enableCapabilities ? false, libcap, buildPackages }:
3 assert enableCapabilities -> stdenv.isLinux;
5 stdenv.mkDerivation rec {
6   pname = "libgcrypt";
7   version = "1.9.2";
9   src = fetchurl {
10     url = "mirror://gnupg/libgcrypt/${pname}-${version}.tar.bz2";
11     sha256 = "sha256-ssENCRUTsnHkcXcnRgex/7o9lbGIu/qHl/lIrskFPFo=";
12   };
14   outputs = [ "out" "dev" "info" ];
15   outputBin = "dev";
17   # The CPU Jitter random number generator must not be compiled with
18   # optimizations and the optimize -O0 pragma only works for gcc.
19   # The build enables -O2 by default for everything else.
20   hardeningDisable = lib.optional stdenv.cc.isClang "fortify";
22   depsBuildBuild = [ buildPackages.stdenv.cc ];
24   buildInputs = [ libgpgerror ]
25     ++ lib.optional stdenv.isDarwin gettext
26     ++ lib.optional enableCapabilities libcap;
28   strictDeps = true;
30   configureFlags = [ "--with-libgpg-error-prefix=${libgpgerror.dev}" ]
31       ++ lib.optional (stdenv.hostPlatform.isMusl || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)) "--disable-asm"; # for darwin see https://dev.gnupg.org/T5157
33   # Necessary to generate correct assembly when compiling for aarch32 on
34   # aarch64
35   configurePlatforms = [ "host" "build" ];
37   postConfigure = ''
38     sed -i configure \
39         -e 's/NOEXECSTACK_FLAGS=$/NOEXECSTACK_FLAGS="-Wa,--noexecstack"/'
40   '';
42   # Make sure libraries are correct for .pc and .la files
43   # Also make sure includes are fixed for callers who don't use libgpgcrypt-config
44   postFixup = ''
45     sed -i 's,#include <gpg-error.h>,#include "${libgpgerror.dev}/include/gpg-error.h",g' "$dev/include/gcrypt.h"
46   '' + lib.optionalString enableCapabilities ''
47     sed -i 's,\(-lcap\),-L${libcap.lib}/lib \1,' $out/lib/libgcrypt.la
48   '';
50   # TODO: figure out why this is even necessary and why the missing dylib only crashes
51   # random instead of every test
52   preCheck = lib.optionalString stdenv.isDarwin ''
53     mkdir -p $out/lib
54     cp src/.libs/libgcrypt.20.dylib $out/lib
55   '';
57   doCheck = true;
59   meta = with lib; {
60     homepage = "https://www.gnu.org/software/libgcrypt/";
61     description = "General-purpose cryptographic library";
62     license = licenses.lgpl2Plus;
63     platforms = platforms.all;
64     maintainers = with maintainers; [ vrthra ];
65     repositories.git = "git://git.gnupg.org/libgcrypt.git";
66   };