1{
2 stdenv,
3 fetchurl,
4 libxml2,
5 gnutls,
6 libxslt,
7 pkg-config,
8 libgcrypt,
9 libtool,
10 openssl,
11 nss,
12 lib,
13 runCommandCC,
14 writeText,
15}:
16
17lib.fix (
18 self:
19 stdenv.mkDerivation rec {
20 pname = "xmlsec";
21 version = "1.3.7";
22
23 src = fetchurl {
24 urls = [
25 "https://www.aleksey.com/xmlsec/download/xmlsec1-${version}.tar.gz"
26
27 # for when the ${version} gets older than the last two
28 "https://www.aleksey.com/xmlsec/download/older-releases/xmlsec1-${version}.tar.gz"
29 ];
30 hash = "sha256-2C6TtpuKogWmFrYpF6JpMiv2Oj6q+zd1AU5hdSsgE+o=";
31 };
32
33 patches = [
34 ./lt_dladdsearchdir.patch
35 ./remove_bsd_base64_decode_flag.patch
36 ];
37
38 postPatch = ''
39 substituteAllInPlace src/dl.c
40 '';
41
42 outputs = [
43 "out"
44 "dev"
45 ];
46
47 nativeBuildInputs = [ pkg-config ];
48
49 buildInputs = [
50 libxml2
51 gnutls
52 libgcrypt
53 libtool
54 openssl
55 nss
56 ];
57
58 propagatedBuildInputs = [
59 # required by xmlsec/transforms.h
60 libxslt
61 ];
62
63 enableParallelBuilding = true;
64 doCheck = true;
65 nativeCheckInputs = [ nss.tools ];
66 preCheck = ''
67 export TMPFOLDER=$(mktemp -d)
68 substituteInPlace tests/testrun.sh --replace 'timestamp=`date +%Y%m%d_%H%M%S`' 'timestamp=19700101_000000'
69 '';
70
71 # enable deprecated soap headers required by lasso
72 # https://dev.entrouvert.org/issues/18771
73 configureFlags = [ "--enable-soap" ];
74
75 # otherwise libxmlsec1-gnutls.so won't find libgcrypt.so, after #909
76 NIX_LDFLAGS = "-lgcrypt";
77
78 postInstall = ''
79 moveToOutput "bin/xmlsec1-config" "$dev"
80 moveToOutput "lib/xmlsec1Conf.sh" "$dev"
81 '';
82
83 passthru.tests.libxmlsec1-crypto =
84 runCommandCC "libxmlsec1-crypto-test"
85 {
86 nativeBuildInputs = [ pkg-config ];
87 buildInputs = [
88 self
89 libxml2
90 libxslt
91 libtool
92 ];
93 }
94 ''
95 $CC $(pkg-config --cflags --libs xmlsec1) -o crypto-test ${writeText "crypto-test.c" ''
96 #include <xmlsec/xmlsec.h>
97 #include <xmlsec/crypto.h>
98
99 int main(int argc, char **argv) {
100 return xmlSecInit() ||
101 xmlSecCryptoDLLoadLibrary(argc > 1 ? argv[1] : 0) ||
102 xmlSecCryptoInit();
103 }
104 ''}
105
106 for crypto in "" gcrypt gnutls nss openssl; do
107 ./crypto-test $crypto
108 done
109 touch $out
110 '';
111
112 meta = with lib; {
113 description = "XML Security Library in C based on libxml2";
114 homepage = "https://www.aleksey.com/xmlsec/";
115 downloadPage = "https://www.aleksey.com/xmlsec/download.html";
116 license = licenses.mit;
117 mainProgram = "xmlsec1";
118 maintainers = [ ];
119 platforms = with platforms; linux ++ darwin;
120 };
121 }
122)