Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ stdenv, fetchurl, libxml2, gnutls, libxslt, pkg-config, libgcrypt, libtool 2, openssl, nss, lib, runCommandCC, writeText }: 3 4lib.fix (self: 5stdenv.mkDerivation rec { 6 pname = "xmlsec"; 7 version = "1.2.34"; 8 9 src = fetchurl { 10 url = "https://www.aleksey.com/xmlsec/download/xmlsec1-${version}.tar.gz"; 11 sha256 = "sha256-Us7UlD81vX0IGKOCmMFSjKSsilRED9cRNKB9LRNwomI="; 12 }; 13 14 patches = [ 15 ./lt_dladdsearchdir.patch 16 ] ++ lib.optionals stdenv.isDarwin [ ./remove_bsd_base64_decode_flag.patch ]; 17 postPatch = '' 18 substituteAllInPlace src/dl.c 19 ''; 20 21 outputs = [ "out" "dev" ]; 22 23 nativeBuildInputs = [ pkg-config ]; 24 25 buildInputs = [ libxml2 gnutls libgcrypt libtool openssl nss ]; 26 27 propagatedBuildInputs = [ 28 # required by xmlsec/transforms.h 29 libxslt 30 ]; 31 32 enableParallelBuilding = true; 33 doCheck = true; 34 nativeCheckInputs = [ nss.tools ]; 35 preCheck = '' 36 substituteInPlace tests/testrun.sh \ 37 --replace 'timestamp=`date +%Y%m%d_%H%M%S`' 'timestamp=19700101_000000' \ 38 --replace 'TMPFOLDER=/tmp' '$(mktemp -d)' 39 ''; 40 41 # enable deprecated soap headers required by lasso 42 # https://dev.entrouvert.org/issues/18771 43 configureFlags = [ "--enable-soap" ]; 44 45 # otherwise libxmlsec1-gnutls.so won't find libgcrypt.so, after #909 46 NIX_LDFLAGS = "-lgcrypt"; 47 48 postInstall = '' 49 moveToOutput "bin/xmlsec1-config" "$dev" 50 moveToOutput "lib/xmlsec1Conf.sh" "$dev" 51 ''; 52 53 passthru.tests.libxmlsec1-crypto = runCommandCC "libxmlsec1-crypto-test" 54 { 55 nativeBuildInputs = [ pkg-config ]; 56 buildInputs = [ self libxml2 libxslt libtool ]; 57 } '' 58 $CC $(pkg-config --cflags --libs xmlsec1) -o crypto-test ${writeText "crypto-test.c" '' 59 #include <xmlsec/xmlsec.h> 60 #include <xmlsec/crypto.h> 61 62 int main(int argc, char **argv) { 63 return xmlSecInit() || 64 xmlSecCryptoDLLoadLibrary(argc > 1 ? argv[1] : 0) || 65 xmlSecCryptoInit(); 66 } 67 ''} 68 69 for crypto in "" gcrypt gnutls nss openssl; do 70 ./crypto-test $crypto 71 done 72 touch $out 73 ''; 74 75 meta = with lib; { 76 description = "XML Security Library in C based on libxml2"; 77 homepage = "https://www.aleksey.com/xmlsec/"; 78 downloadPage = "https://www.aleksey.com/xmlsec/download.html"; 79 license = licenses.mit; 80 mainProgram = "xmlsec1"; 81 maintainers = with maintainers; [ ]; 82 platforms = with platforms; linux ++ darwin; 83 }; 84} 85)