2022-10-21 18:38:19 +00:00
{ lib , stdenv , fetchFromGitHub , rustPlatform , napi-rs-cli , nodejs , libiconv }:
stdenv . mkDerivation rec {
pname = " m a t r i x - s d k - c r y p t o - n o d e j s " ;
2023-04-29 16:46:19 +00:00
version = " 0 . 1 . 0 - b e t a . 3 " ;
2022-10-21 18:38:19 +00:00
src = fetchFromGitHub {
owner = " m a t r i x - o r g " ;
repo = " m a t r i x - r u s t - s d k " ;
rev = " ${ pname } - v ${ version } " ;
2023-04-29 16:46:19 +00:00
hash = " s h a 2 5 6 - 0 p + 1 c M n 9 P U + J k 2 J W 7 G + s d z x h M a I 3 g E A k 5 w 2 n m 0 5 o B S U = " ;
2022-10-21 18:38:19 +00:00
} ;
patches = [
# This is needed because two versions of indexed_db_futures are present (which will fail to vendor, see https://github.com/rust-lang/cargo/issues/10310).
# (matrix-sdk-crypto-nodejs doesn't use this dependency, we only need to remove it to vendor the dependencies successfully.)
./remove-duplicate-dependency.patch
] ;
2023-04-29 16:46:19 +00:00
cargoDeps = rustPlatform . importCargoLock {
lockFile = ./Cargo.lock ;
outputHashes = {
" u n i f f i - 0 . 2 1 . 0 " = " s h a 2 5 6 - b l K C f C s S N t r 8 N t O 7 L e t 7 V J / 9 o G u W 9 E u 8 j 9 A 6 / o H U c P 0 = " ;
} ;
2022-10-21 18:38:19 +00:00
} ;
nativeBuildInputs = [
rustPlatform . cargoSetupHook
rustPlatform . rust . cargo
rustPlatform . rust . rustc
napi-rs-cli
nodejs
] ;
buildInputs = lib . optionals stdenv . isDarwin [ libiconv ] ;
buildPhase = ''
runHook preBuild
cd bindings / $ { pname }
npm run release-build - - offline
runHook postBuild
'' ;
installPhase = ''
runHook preInstall
local - r outPath = " $ o u t / l i b / n o d e _ m o d u l e s / @ m a t r i x - o r g / ${ pname } "
mkdir - p " $ o u t P a t h "
cp package . json index . js index . d . ts matrix-sdk-crypto . * . node " $ o u t P a t h "
runHook postInstall
'' ;
meta = with lib ; {
description = " A n o - n e t w o r k - I O i m p l e m e n t a t i o n o f a s t a t e m a c h i n e t h a t h a n d l e s E 2 E E f o r M a t r i x c l i e n t s " ;
homepage = " h t t p s : / / g i t h u b . c o m / m a t r i x - o r g / m a t r i x - r u s t - s d k / t r e e / ${ src . rev } / b i n d i n g s / m a t r i x - s d k - c r y p t o - n o d e j s " ;
license = licenses . asl20 ;
maintainers = with maintainers ; [ winter ] ;
inherit ( nodejs . meta ) platforms ;
} ;
}