2019-08-26 20:13:57 +01:00
|
|
|
|
{ lib, boringssl, stdenv, fetchgit, fetchFromGitHub, cmake, zlib, perl, libevent }:
|
|
|
|
|
let
|
2022-03-02 10:53:08 +00:00
|
|
|
|
versions = builtins.fromJSON (builtins.readFile ./versions.json);
|
|
|
|
|
|
2019-08-26 20:13:57 +01:00
|
|
|
|
# lsquic requires a specific boringssl version (noted in its README)
|
2022-03-02 10:53:08 +00:00
|
|
|
|
boringssl' = boringssl.overrideAttrs (old: {
|
|
|
|
|
version = versions.boringssl.rev;
|
2019-08-26 20:13:57 +01:00
|
|
|
|
src = fetchgit {
|
|
|
|
|
url = "https://boringssl.googlesource.com/boringssl";
|
2022-03-02 10:53:08 +00:00
|
|
|
|
inherit (versions.boringssl) rev sha256;
|
2019-08-26 20:13:57 +01:00
|
|
|
|
};
|
2021-11-14 09:07:09 +00:00
|
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
|
# Use /etc/ssl/certs/ca-certificates.crt instead of /etc/ssl/cert.pem
|
|
|
|
|
./use-etc-ssl-certs.patch
|
|
|
|
|
];
|
2019-08-26 20:13:57 +01:00
|
|
|
|
});
|
|
|
|
|
in
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
|
pname = "lsquic";
|
2022-03-02 10:53:08 +00:00
|
|
|
|
version = versions.lsquic.version;
|
2019-08-26 20:13:57 +01:00
|
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
|
owner = "litespeedtech";
|
|
|
|
|
repo = pname;
|
|
|
|
|
rev = "v${version}";
|
2022-03-02 10:53:08 +00:00
|
|
|
|
inherit (versions.lsquic) sha256;
|
2019-08-26 20:13:57 +01:00
|
|
|
|
fetchSubmodules = true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cmake perl ];
|
|
|
|
|
buildInputs = [ boringssl' libevent zlib ];
|
|
|
|
|
|
|
|
|
|
cmakeFlags = [
|
2021-11-27 06:21:55 +00:00
|
|
|
|
"-DBORINGSSL_DIR=${lib.getDev boringssl'}"
|
|
|
|
|
"-DBORINGSSL_LIB_crypto=${lib.getLib boringssl'}/lib/libcrypto.a"
|
|
|
|
|
"-DBORINGSSL_LIB_ssl=${lib.getLib boringssl'}/lib/libssl.a"
|
2019-08-26 20:13:57 +01:00
|
|
|
|
"-DZLIB_LIB=${zlib}/lib/libz.so"
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
# adapted from lsquic.cr’s Dockerfile
|
|
|
|
|
# (https://github.com/iv-org/lsquic.cr/blob/master/docker/Dockerfile)
|
|
|
|
|
installPhase = ''
|
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
|
|
mkdir combinedlib
|
|
|
|
|
cd combinedlib
|
2021-11-27 06:21:55 +00:00
|
|
|
|
ar -x ${lib.getLib boringssl'}/lib/libssl.a
|
|
|
|
|
ar -x ${lib.getLib boringssl'}/lib/libcrypto.a
|
2019-08-26 20:13:57 +01:00
|
|
|
|
ar -x ../src/liblsquic/liblsquic.a
|
|
|
|
|
ar rc liblsquic.a *.o
|
|
|
|
|
ranlib liblsquic.a
|
|
|
|
|
install -D liblsquic.a $out/lib/liblsquic.a
|
|
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
|
'';
|
|
|
|
|
|
2022-03-02 10:53:08 +00:00
|
|
|
|
passthru.boringssl = boringssl';
|
|
|
|
|
|
2019-08-26 20:13:57 +01:00
|
|
|
|
meta = with lib; {
|
|
|
|
|
description = "A library for QUIC and HTTP/3 (version for Invidious)";
|
|
|
|
|
homepage = "https://github.com/litespeedtech/lsquic";
|
|
|
|
|
maintainers = with maintainers; [ infinisil sbruder ];
|
|
|
|
|
license = with licenses; [ openssl isc mit bsd3 ]; # statically links against boringssl, so has to include its licenses
|
|
|
|
|
};
|
|
|
|
|
}
|