1{ lib, fetchurl, stdenv, zlib, lzo, libtasn1, nettle, pkgconfig, lzip
2, guileBindings, guile, perl, gmp, autogen, libidn, p11-kit, libiconv
3, tpmSupport ? false, trousers, which, nettools, libunistring
4, unbound, dns-root-data, gettext
5
6# Version dependent args
7, version, src, patches ? [], postPatch ? "", nativeBuildInputs ? []
8, buildInputs ? []
9, ...}:
10
11assert guileBindings -> guile != null;
12let
13 # XXX: Gnulib's `test-select' fails on FreeBSD:
14 # http://hydra.nixos.org/build/2962084/nixlog/1/raw .
15 doCheck = !stdenv.isFreeBSD && !stdenv.isDarwin && lib.versionAtLeast version "3.4"
16 && stdenv.buildPlatform == stdenv.hostPlatform;
17in
18stdenv.mkDerivation {
19 name = "gnutls-${version}";
20
21 inherit src patches;
22
23 outputs = [ "bin" "dev" "out" "man" "devdoc" ];
24 outputInfo = "devdoc";
25
26 postPatch = lib.optionalString (lib.versionAtLeast version "3.4") ''
27 sed '2iecho "name constraints tests skipped due to datefudge problems"\nexit 0' \
28 -i tests/cert-tests/name-constraints
29 '' + postPatch;
30
31 preConfigure = "patchShebangs .";
32 configureFlags =
33 lib.optional stdenv.isLinux "--with-default-trust-store-file=/etc/ssl/certs/ca-certificates.crt"
34 ++ [
35 "--disable-dependency-tracking"
36 "--enable-fast-install"
37 "--with-unbound-root-key-file=${dns-root-data}/root.key"
38 ] ++ lib.optional guileBindings
39 [ "--enable-guile" "--with-guile-site-dir=\${out}/share/guile/site" ];
40
41 enableParallelBuilding = true;
42
43 buildInputs = [ lzo lzip libtasn1 libidn p11-kit zlib gmp autogen libunistring unbound ]
44 ++ lib.optional (stdenv.isFreeBSD || stdenv.isDarwin) libiconv
45 ++ lib.optional stdenv.isDarwin gettext
46 ++ lib.optional (tpmSupport && stdenv.isLinux) trousers
47 ++ lib.optional guileBindings guile
48 ++ buildInputs;
49
50 nativeBuildInputs = [ perl pkgconfig ] ++ nativeBuildInputs
51 ++ lib.optionals doCheck [ which nettools ];
52
53 propagatedBuildInputs = [ nettle ];
54
55 inherit doCheck;
56
57 # Fixup broken libtool and pkgconfig files
58 preFixup = lib.optionalString (!stdenv.isDarwin) ''
59 sed ${lib.optionalString tpmSupport "-e 's,-ltspi,-L${trousers}/lib -ltspi,'"} \
60 -e 's,-lz,-L${zlib.out}/lib -lz,' \
61 -e 's,-L${gmp.dev}/lib,-L${gmp.out}/lib,' \
62 -e 's,-lgmp,-L${gmp.out}/lib -lgmp,' \
63 -i $out/lib/*.la "$dev/lib/pkgconfig/gnutls.pc"
64 '' + ''
65 # It seems only useful for static linking but basically noone does that.
66 substituteInPlace "$out/lib/libgnutls.la" \
67 --replace "-lunistring" ""
68 '';
69
70 meta = with lib; {
71 description = "The GNU Transport Layer Security Library";
72
73 longDescription = ''
74 GnuTLS is a project that aims to develop a library which
75 provides a secure layer, over a reliable transport
76 layer. Currently the GnuTLS library implements the proposed standards by
77 the IETF's TLS working group.
78
79 Quoting from the TLS protocol specification:
80
81 "The TLS protocol provides communications privacy over the
82 Internet. The protocol allows client/server applications to
83 communicate in a way that is designed to prevent eavesdropping,
84 tampering, or message forgery."
85 '';
86
87 homepage = http://www.gnu.org/software/gnutls/;
88 license = licenses.lgpl21Plus;
89 maintainers = with maintainers; [ eelco wkennington fpletz ];
90 platforms = platforms.all;
91 };
92}