2021-01-19 07:50:56 +01:00
|
|
|
{ config, lib, stdenv, fetchurl, zlib, lzo, libtasn1, nettle, pkg-config, lzip
|
2022-01-24 20:18:39 +01:00
|
|
|
, perl, gmp, autoconf, automake, libidn2, libiconv
|
2021-11-02 11:05:31 +01:00
|
|
|
, unbound, dns-root-data, gettext, util-linux
|
2021-11-03 19:02:59 +01:00
|
|
|
, cxxBindings ? !stdenv.hostPlatform.isStatic # tries to link libstdc++.so
|
2019-02-03 16:33:26 +01:00
|
|
|
, guileBindings ? config.gnutls.guile or false, guile
|
2017-03-13 10:28:53 +01:00
|
|
|
, tpmSupport ? false, trousers, which, nettools, libunistring
|
2021-11-03 19:02:59 +01:00
|
|
|
, withP11-kit ? !stdenv.hostPlatform.isStatic, p11-kit
|
2022-06-26 08:56:24 +02:00
|
|
|
, withSecurity ? true, Security # darwin Security.framework
|
2022-06-23 09:13:57 +02:00
|
|
|
# certificate compression - only zlib now, more possible: zstd, brotli
|
2019-03-31 11:59:16 +02:00
|
|
|
}:
|
2015-04-04 04:16:33 +02:00
|
|
|
|
|
|
|
assert guileBindings -> guile != null;
|
2016-07-09 15:15:42 +02:00
|
|
|
let
|
2019-03-31 11:59:16 +02:00
|
|
|
|
2016-07-09 15:15:42 +02:00
|
|
|
# XXX: Gnulib's `test-select' fails on FreeBSD:
|
2020-04-18 22:51:19 +02:00
|
|
|
# https://hydra.nixos.org/build/2962084/nixlog/1/raw .
|
2021-06-11 06:53:41 +02:00
|
|
|
doCheck = !stdenv.isFreeBSD && !stdenv.isDarwin
|
2017-10-27 03:53:57 +02:00
|
|
|
&& stdenv.buildPlatform == stdenv.hostPlatform;
|
2019-03-31 11:59:16 +02:00
|
|
|
|
|
|
|
inherit (stdenv.hostPlatform) isDarwin;
|
2016-07-09 15:15:42 +02:00
|
|
|
in
|
2019-03-31 11:59:16 +02:00
|
|
|
|
2021-06-11 06:53:41 +02:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "gnutls";
|
2022-08-08 10:57:29 +02:00
|
|
|
version = "3.7.7";
|
2015-04-04 04:16:33 +02:00
|
|
|
|
2019-03-31 11:59:16 +02:00
|
|
|
src = fetchurl {
|
2021-06-16 08:50:04 +02:00
|
|
|
url = "mirror://gnupg/gnutls/v${lib.versions.majorMinor version}/gnutls-${version}.tar.xz";
|
2022-08-08 10:57:29 +02:00
|
|
|
sha256 = "sha256-vpFD0NWOq2TbqbdxFKqvrFKbbA1+gd5r3xybWQJ9IQY=";
|
2019-03-31 11:59:16 +02:00
|
|
|
};
|
2015-04-04 04:16:33 +02:00
|
|
|
|
2016-09-01 11:07:23 +02:00
|
|
|
outputs = [ "bin" "dev" "out" "man" "devdoc" ];
|
2020-02-10 21:34:46 +01:00
|
|
|
# Not normally useful docs.
|
2016-09-01 11:07:23 +02:00
|
|
|
outputInfo = "devdoc";
|
2020-02-10 21:34:46 +01:00
|
|
|
outputDoc = "devdoc";
|
2015-07-27 00:25:53 +02:00
|
|
|
|
2019-04-22 10:49:11 +02:00
|
|
|
patches = [ ./nix-ssl-cert-file.patch ]
|
|
|
|
# Disable native add_system_trust.
|
2022-06-27 09:51:49 +02:00
|
|
|
# FIXME: apparently it's not enough to drop the framework anymore; maybe related to
|
|
|
|
# https://gitlab.com/gnutls/gnutls/-/commit/c19cb93d492e45141bfef9b926dfeba36003261c
|
2021-04-16 05:47:25 +02:00
|
|
|
++ lib.optional (isDarwin && !withSecurity) ./no-security-framework.patch;
|
2019-03-31 11:59:16 +02:00
|
|
|
|
|
|
|
# Skip some tests:
|
2021-01-19 07:50:56 +01:00
|
|
|
# - pkg-config: building against the result won't work before installing (3.5.11)
|
2019-03-31 11:59:16 +02:00
|
|
|
# - fastopen: no idea; it broke between 3.6.2 and 3.6.3 (3437fdde6 in particular)
|
|
|
|
# - trust-store: default trust store path (/etc/ssl/...) is missing in sandbox (3.5.11)
|
|
|
|
# - psk-file: no idea; it broke between 3.6.3 and 3.6.4
|
|
|
|
# Change p11-kit test to use pkg-config to find p11-kit
|
2021-06-11 06:53:41 +02:00
|
|
|
postPatch = ''
|
2019-03-31 11:59:16 +02:00
|
|
|
sed '2iexit 77' -i tests/{pkgconfig,fastopen}.sh
|
|
|
|
sed '/^void doit(void)/,/^{/ s/{/{ exit(77);/' -i tests/{trust-store,psk-file}.c
|
|
|
|
sed 's:/usr/lib64/pkcs11/ /usr/lib/pkcs11/ /usr/lib/x86_64-linux-gnu/pkcs11/:`pkg-config --variable=p11_module_path p11-kit-1`:' -i tests/p11-kit-trust.sh
|
2020-05-06 16:58:58 +02:00
|
|
|
'' + lib.optionalString stdenv.hostPlatform.isMusl '' # See https://gitlab.com/gnutls/gnutls/-/issues/945
|
2021-04-16 08:48:27 +02:00
|
|
|
sed '2iecho "certtool tests skipped in musl build"\nexit 0' -i tests/cert-tests/certtool.sh
|
2019-03-31 11:59:16 +02:00
|
|
|
'';
|
2016-06-30 11:06:34 +02:00
|
|
|
|
|
|
|
preConfigure = "patchShebangs .";
|
2015-06-11 09:02:56 +02:00
|
|
|
configureFlags =
|
2021-11-03 19:02:59 +01:00
|
|
|
lib.optionals withP11-kit [
|
2021-11-17 23:50:53 +01:00
|
|
|
"--with-default-trust-store-file=/etc/ssl/certs/ca-certificates.crt"
|
|
|
|
"--with-default-trust-store-pkcs11=pkcs11:"
|
|
|
|
] ++ [
|
2015-04-19 09:49:15 +02:00
|
|
|
"--disable-dependency-tracking"
|
|
|
|
"--enable-fast-install"
|
2017-06-16 05:11:56 +02:00
|
|
|
"--with-unbound-root-key-file=${dns-root-data}/root.key"
|
2021-11-03 19:02:59 +01:00
|
|
|
(lib.withFeature withP11-kit "p11-kit")
|
|
|
|
(lib.enableFeature cxxBindings "cxx")
|
2020-02-15 21:54:01 +01:00
|
|
|
] ++ lib.optional guileBindings [
|
|
|
|
"--enable-guile"
|
|
|
|
"--with-guile-site-dir=\${out}/share/guile/site"
|
|
|
|
"--with-guile-site-ccache-dir=\${out}/share/guile/site"
|
|
|
|
"--with-guile-extension-dir=\${out}/share/guile/site"
|
|
|
|
];
|
2015-04-04 04:16:33 +02:00
|
|
|
|
2016-10-24 20:22:52 +02:00
|
|
|
enableParallelBuilding = true;
|
2015-04-04 04:16:33 +02:00
|
|
|
|
2022-01-24 20:18:39 +01:00
|
|
|
buildInputs = [ lzo lzip libtasn1 libidn2 zlib gmp libunistring unbound gettext libiconv ]
|
2021-11-03 19:02:59 +01:00
|
|
|
++ lib.optional (withP11-kit) p11-kit
|
2015-07-26 12:37:57 +02:00
|
|
|
++ lib.optional (tpmSupport && stdenv.isLinux) trousers
|
2019-03-31 11:59:16 +02:00
|
|
|
++ lib.optional guileBindings guile;
|
2015-04-04 04:16:33 +02:00
|
|
|
|
2021-01-19 07:50:56 +01:00
|
|
|
nativeBuildInputs = [ perl pkg-config ]
|
2019-03-31 11:59:16 +02:00
|
|
|
++ lib.optionals (isDarwin && !withSecurity) [ autoconf automake ]
|
2020-11-24 16:29:28 +01:00
|
|
|
++ lib.optionals doCheck [ which nettools util-linux ];
|
2015-04-04 04:16:33 +02:00
|
|
|
|
2022-06-27 09:51:49 +02:00
|
|
|
propagatedBuildInputs = [ nettle ]
|
|
|
|
# Builds dynamically linking against gnutls seem to need the framework now.
|
|
|
|
++ lib.optional (isDarwin && withSecurity) Security;
|
2017-02-05 13:37:16 +01:00
|
|
|
|
2016-07-09 15:15:42 +02:00
|
|
|
inherit doCheck;
|
2021-11-02 11:05:31 +01:00
|
|
|
# stdenv's `NIX_SSL_CERT_FILE=/no-cert-file.crt` breaks tests.
|
|
|
|
# Also empty files won't work, and we want to avoid potentially impure /etc/
|
|
|
|
preCheck = "NIX_SSL_CERT_FILE=${./dummy.crt}";
|
2015-04-04 04:16:33 +02:00
|
|
|
|
2021-01-19 07:50:56 +01:00
|
|
|
# Fixup broken libtool and pkg-config files
|
2019-03-31 11:59:16 +02:00
|
|
|
preFixup = lib.optionalString (!isDarwin) ''
|
2015-07-26 12:37:57 +02:00
|
|
|
sed ${lib.optionalString tpmSupport "-e 's,-ltspi,-L${trousers}/lib -ltspi,'"} \
|
2015-04-27 13:18:16 +02:00
|
|
|
-e 's,-lz,-L${zlib.out}/lib -lz,' \
|
2015-10-15 17:43:23 +02:00
|
|
|
-e 's,-L${gmp.dev}/lib,-L${gmp.out}/lib,' \
|
2015-10-17 22:53:54 +02:00
|
|
|
-e 's,-lgmp,-L${gmp.out}/lib -lgmp,' \
|
|
|
|
-i $out/lib/*.la "$dev/lib/pkgconfig/gnutls.pc"
|
2017-02-22 17:44:06 +01:00
|
|
|
'' + ''
|
2017-02-20 23:17:10 +01:00
|
|
|
# It seems only useful for static linking but basically noone does that.
|
|
|
|
substituteInPlace "$out/lib/libgnutls.la" \
|
|
|
|
--replace "-lunistring" ""
|
2015-04-25 11:36:38 +02:00
|
|
|
'';
|
|
|
|
|
2015-07-26 12:37:57 +02:00
|
|
|
meta = with lib; {
|
2015-04-04 04:16:33 +02:00
|
|
|
description = "The GNU Transport Layer Security Library";
|
|
|
|
|
|
|
|
longDescription = ''
|
|
|
|
GnuTLS is a project that aims to develop a library which
|
|
|
|
provides a secure layer, over a reliable transport
|
|
|
|
layer. Currently the GnuTLS library implements the proposed standards by
|
|
|
|
the IETF's TLS working group.
|
|
|
|
|
|
|
|
Quoting from the TLS protocol specification:
|
|
|
|
|
|
|
|
"The TLS protocol provides communications privacy over the
|
|
|
|
Internet. The protocol allows client/server applications to
|
|
|
|
communicate in a way that is designed to prevent eavesdropping,
|
|
|
|
tampering, or message forgery."
|
|
|
|
'';
|
|
|
|
|
2021-06-16 15:14:38 +02:00
|
|
|
homepage = "https://gnutls.org/";
|
2015-04-04 04:16:33 +02:00
|
|
|
license = licenses.lgpl21Plus;
|
2022-08-10 20:14:13 +02:00
|
|
|
maintainers = with maintainers; [ vcunat ];
|
2015-04-04 04:16:33 +02:00
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
}
|