nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at 22.05 82 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.1"; 19 20 src = fetchurl { 21 url = "mirror://gnupg/libgcrypt/${pname}-${version}.tar.bz2"; 22 hash = "sha256-7xSuVGsAhM2EJZ9hpV4Ho4w7U6/A9Ua//O8vAbr/6d4="; 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 # Make sure libraries are correct for .pc and .la files 54 # Also make sure includes are fixed for callers who don't use libgpgcrypt-config 55 postFixup = '' 56 sed -i 's,#include <gpg-error.h>,#include "${libgpg-error.dev}/include/gpg-error.h",g' "$dev/include/gcrypt.h" 57 '' + lib.optionalString enableCapabilities '' 58 sed -i 's,\(-lcap\),-L${libcap.lib}/lib \1,' $out/lib/libgcrypt.la 59 ''; 60 61 # TODO: figure out why this is even necessary and why the missing dylib only crashes 62 # random instead of every test 63 preCheck = lib.optionalString stdenv.isDarwin '' 64 mkdir -p $out/lib 65 cp src/.libs/libgcrypt.20.dylib $out/lib 66 ''; 67 68 doCheck = true; 69 70 passthru.tests = { 71 inherit gnupg libotr rsyslog; 72 }; 73 74 meta = with lib; { 75 homepage = "https://www.gnu.org/software/libgcrypt/"; 76 changelog = "https://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgcrypt.git;a=blob;f=NEWS;hb=refs/tags/${pname}-${version}"; 77 description = "General-purpose cryptographic library"; 78 license = licenses.lgpl2Plus; 79 platforms = platforms.all; 80 maintainers = with maintainers; [ vrthra ]; 81 }; 82}