Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 24.05-beta 85 lines 2.6 kB view raw
1{ lib 2, stdenv 3, fetchurl 4, gettext 5, libgpg-error 6, enableCapabilities ? false, libcap 7, buildPackages 8# for passthru.tests 9, gnupg 10, libotr 11, rsyslog 12}: 13 14assert enableCapabilities -> stdenv.isLinux; 15 16stdenv.mkDerivation rec { 17 pname = "libgcrypt"; 18 version = "1.10.3"; 19 20 src = fetchurl { 21 url = "mirror://gnupg/libgcrypt/${pname}-${version}.tar.bz2"; 22 hash = "sha256-iwhwiXrFrGfe1Wjc+t9Flpz6imvrD9YK8qnq3Coycqo="; 23 }; 24 25 outputs = [ "out" "dev" "info" ]; 26 outputBin = "dev"; 27 28 # The CPU Jitter random number generator must not be compiled with 29 # optimizations and the optimize -O0 pragma only works for gcc. 30 # The build enables -O2 by default for everything else. 31 hardeningDisable = lib.optional stdenv.cc.isClang "fortify"; 32 33 depsBuildBuild = [ buildPackages.stdenv.cc ]; 34 35 buildInputs = [ libgpg-error ] 36 ++ lib.optional stdenv.isDarwin gettext 37 ++ lib.optional enableCapabilities libcap; 38 39 strictDeps = true; 40 41 configureFlags = [ "--with-libgpg-error-prefix=${libgpg-error.dev}" ] 42 ++ lib.optional (stdenv.hostPlatform.isMusl || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)) "--disable-asm"; # for darwin see https://dev.gnupg.org/T5157 43 44 # Necessary to generate correct assembly when compiling for aarch32 on 45 # aarch64 46 configurePlatforms = [ "host" "build" ]; 47 48 postConfigure = '' 49 sed -i configure \ 50 -e 's/NOEXECSTACK_FLAGS=$/NOEXECSTACK_FLAGS="-Wa,--noexecstack"/' 51 ''; 52 53 enableParallelBuilding = true; 54 55 # Make sure libraries are correct for .pc and .la files 56 # Also make sure includes are fixed for callers who don't use libgpgcrypt-config 57 postFixup = '' 58 sed -i 's,#include <gpg-error.h>,#include "${libgpg-error.dev}/include/gpg-error.h",g' "$dev/include/gcrypt.h" 59 '' + lib.optionalString enableCapabilities '' 60 sed -i 's,\(-lcap\),-L${libcap.lib}/lib \1,' $out/lib/libgcrypt.la 61 ''; 62 63 # TODO: figure out why this is even necessary and why the missing dylib only crashes 64 # random instead of every test 65 preCheck = lib.optionalString stdenv.isDarwin '' 66 mkdir -p $out/lib 67 cp src/.libs/libgcrypt.20.dylib $out/lib 68 ''; 69 70 doCheck = true; 71 enableParallelChecking = true; 72 73 passthru.tests = { 74 inherit gnupg libotr rsyslog; 75 }; 76 77 meta = with lib; { 78 homepage = "https://www.gnu.org/software/libgcrypt/"; 79 changelog = "https://git.gnupg.org/cgi-bin/gitweb.cgi?p=${pname}.git;a=blob;f=NEWS;hb=refs/tags/${pname}-${version}"; 80 description = "General-purpose cryptographic library"; 81 license = licenses.lgpl2Plus; 82 platforms = platforms.all; 83 maintainers = with maintainers; [ vrthra ]; 84 }; 85}