depot/third_party/nixpkgs/pkgs/by-name/ru/rustls-ffi/package.nix

84 lines
2 KiB
Nix

{
lib,
stdenv,
fetchFromGitHub,
cargo,
rustPlatform,
cargo-c,
validatePkgConfig,
rust,
libiconv,
darwin,
curl,
apacheHttpd,
testers,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "rustls-ffi";
version = "0.14.1";
src = fetchFromGitHub {
owner = "rustls";
repo = "rustls-ffi";
rev = "v${finalAttrs.version}";
hash = "sha256-ZKAyKcKwhnPE6PrfBFjLJKkTlGbdLcmW1EP/xSv2cpM=";
};
cargoDeps = rustPlatform.fetchCargoTarball {
src = finalAttrs.src;
name = "${finalAttrs.pname}-${finalAttrs.version}";
hash = "sha256-IaOhQfDEgLhGmes0xzhLVym29aP691TY0EXdOIgXEMA=";
};
propagatedBuildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
libiconv
darwin.apple_sdk.frameworks.Security
];
nativeBuildInputs = [
cargo
rustPlatform.cargoSetupHook
cargo-c
validatePkgConfig
];
buildPhase = ''
runHook preBuild
${rust.envVars.setEnv} cargo cbuild -j $NIX_BUILD_CORES --release --frozen --prefix=${placeholder "out"} --target ${stdenv.hostPlatform.rust.rustcTarget}
runHook postBuild
'';
installPhase = ''
runHook preInstall
${rust.envVars.setEnv} cargo cinstall -j $NIX_BUILD_CORES --release --frozen --prefix=${placeholder "out"} --target ${stdenv.hostPlatform.rust.rustcTarget}
runHook postInstall
'';
checkPhase = ''
runHook preCheck
${rust.envVars.setEnv} cargo ctest -j $NIX_BUILD_CORES --release --frozen --prefix=${placeholder "out"} --target ${stdenv.hostPlatform.rust.rustcTarget}
runHook postCheck
'';
passthru.tests = {
curl = curl.override {
opensslSupport = false;
rustlsSupport = true;
rustls-ffi = finalAttrs.finalPackage;
};
pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
};
meta = with lib; {
description = "C-to-rustls bindings";
homepage = "https://github.com/rustls/rustls-ffi/";
pkgConfigModules = [ "rustls" ];
license = with lib.licenses; [
mit
asl20
isc
];
maintainers = [ maintainers.lesuisse ];
};
})