Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 21.11 68 lines 2.5 kB view raw
1{ lib, stdenv, fetchurl, gettext, libgpg-error, enableCapabilities ? false, libcap, buildPackages }: 2 3assert enableCapabilities -> stdenv.isLinux; 4 5stdenv.mkDerivation rec { 6 pname = "libgcrypt"; 7 version = "1.9.4"; 8 9 src = fetchurl { 10 url = "mirror://gnupg/libgcrypt/${pname}-${version}.tar.bz2"; 11 sha256 = "1xxabjv45zlxyryiwhmbfblsx41kl267wsb78bny6m14ly1rr17a"; 12 }; 13 14 outputs = [ "out" "dev" "info" ]; 15 outputBin = "dev"; 16 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"; 21 22 depsBuildBuild = [ buildPackages.stdenv.cc ]; 23 24 buildInputs = [ libgpg-error ] 25 ++ lib.optional stdenv.isDarwin gettext 26 ++ lib.optional enableCapabilities libcap; 27 28 strictDeps = true; 29 30 configureFlags = [ "--with-libgpg-error-prefix=${libgpg-error.dev}" ] 31 ++ lib.optional (stdenv.hostPlatform.isMusl || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)) "--disable-asm"; # for darwin see https://dev.gnupg.org/T5157 32 33 # Necessary to generate correct assembly when compiling for aarch32 on 34 # aarch64 35 configurePlatforms = [ "host" "build" ]; 36 37 postConfigure = '' 38 sed -i configure \ 39 -e 's/NOEXECSTACK_FLAGS=$/NOEXECSTACK_FLAGS="-Wa,--noexecstack"/' 40 ''; 41 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 "${libgpg-error.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 ''; 49 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 ''; 56 57 doCheck = true; 58 59 meta = with lib; { 60 homepage = "https://www.gnu.org/software/libgcrypt/"; 61 changelog = "https://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgcrypt.git;a=blob;f=NEWS;hb=refs/tags/${pname}-${version}"; 62 description = "General-purpose cryptographic library"; 63 license = licenses.lgpl2Plus; 64 platforms = platforms.all; 65 maintainers = with maintainers; [ vrthra ]; 66 repositories.git = "git://git.gnupg.org/libgcrypt.git"; 67 }; 68}