1 { lib, stdenv, fetchFromGitHub, rustPlatform, napi-rs-cli, nodejs, libiconv }:
3 stdenv.mkDerivation rec {
4 pname = "matrix-sdk-crypto-nodejs";
5 version = "0.1.0-beta.2";
7 src = fetchFromGitHub {
9 repo = "matrix-rust-sdk";
10 rev = "${pname}-v${version}";
11 hash = "sha256-E++0tm/2d8/3zAXwovJ71uF2sxDORWyJNnA3e1Q3NLA=";
15 # 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).
16 # (matrix-sdk-crypto-nodejs doesn't use this dependency, we only need to remove it to vendor the dependencies successfully.)
17 ./remove-duplicate-dependency.patch
20 cargoDeps = rustPlatform.fetchCargoTarball {
22 name = "${pname}-${version}";
23 hash = "sha256-G2Um7vHinOuOx9U2BH14LAx+s/0Sxtlc9Nz6nPJfmU8=";
27 rustPlatform.cargoSetupHook
28 rustPlatform.rust.cargo
29 rustPlatform.rust.rustc
34 buildInputs = lib.optionals stdenv.isDarwin [ libiconv ];
40 npm run release-build --offline
48 local -r outPath="$out/lib/node_modules/@matrix-org/${pname}"
50 cp package.json index.js index.d.ts matrix-sdk-crypto.*.node "$outPath"
56 description = "A no-network-IO implementation of a state machine that handles E2EE for Matrix clients";
57 homepage = "https://github.com/matrix-org/matrix-rust-sdk/tree/${src.rev}/bindings/matrix-sdk-crypto-nodejs";
58 license = licenses.asl20;
59 maintainers = with maintainers; [ winter ];
60 inherit (nodejs.meta) platforms;