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