From fd3364708931e0711764e3232f76a48b976b4a2d Mon Sep 17 00:00:00 2001 From: Winter Date: Thu, 6 Oct 2022 21:27:23 -0400 Subject: [PATCH 1/2] napi-rs-cli: init at 2.12.0 --- .../development/tools/napi-rs-cli/default.nix | 33 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 2 files changed, 35 insertions(+) create mode 100644 pkgs/development/tools/napi-rs-cli/default.nix diff --git a/pkgs/development/tools/napi-rs-cli/default.nix b/pkgs/development/tools/napi-rs-cli/default.nix new file mode 100644 index 0000000000000..e32658713866f --- /dev/null +++ b/pkgs/development/tools/napi-rs-cli/default.nix @@ -0,0 +1,33 @@ +{ lib, stdenv, fetchurl, makeWrapper, nodejs }: + +stdenv.mkDerivation rec { + pname = "napi-rs-cli"; + version = "2.12.0"; + + src = fetchurl { + url = "https://registry.npmjs.org/@napi-rs/cli/-/cli-${version}.tgz"; + hash = "sha256-TGhPPv73tb3tr1cY9mUuN4FaVql5tGh436uJeTkbnJs="; + }; + + nativeBuildInputs = [ makeWrapper ]; + + installPhase = '' + runHook preInstall + + mkdir -p "$out/bin" "$out/lib/napi-rs-cli" + + cp scripts/index.js "$out/lib/napi-rs-cli" + + makeWrapper ${nodejs}/bin/node "$out/bin/napi" --add-flags "$out/lib/napi-rs-cli/index.js" + + runHook postInstall + ''; + + meta = with lib; { + description = "CLI tools for napi-rs"; + homepage = "https://napi.rs"; + license = licenses.mit; + maintainers = with maintainers; [ winter ]; + inherit (nodejs.meta) platforms; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 9cfdc1f70e020..69b73a4169a8c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -9477,6 +9477,8 @@ with pkgs; pwsafe = callPackage ../applications/misc/pwsafe { }; + napi-rs-cli = callPackage ../development/tools/napi-rs-cli { }; + neil = callPackage ../development/tools/neil { }; niff = callPackage ../tools/package-management/niff { }; From cb6c372c1b41d2fa61370bb23a11296c11e134f8 Mon Sep 17 00:00:00 2001 From: Winter Date: Thu, 6 Oct 2022 21:55:25 -0400 Subject: [PATCH 2/2] matrix-sdk-crypto-nodejs: init at 0.1.0-beta.2 --- .../matrix-sdk-crypto-nodejs/default.nix | 65 +++++++++++++++++++ .../remove-duplicate-dependency.patch | 47 ++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 3 files changed, 114 insertions(+) create mode 100644 pkgs/development/libraries/matrix-sdk-crypto-nodejs/default.nix create mode 100644 pkgs/development/libraries/matrix-sdk-crypto-nodejs/remove-duplicate-dependency.patch diff --git a/pkgs/development/libraries/matrix-sdk-crypto-nodejs/default.nix b/pkgs/development/libraries/matrix-sdk-crypto-nodejs/default.nix new file mode 100644 index 0000000000000..afb52ddd6b3c8 --- /dev/null +++ b/pkgs/development/libraries/matrix-sdk-crypto-nodejs/default.nix @@ -0,0 +1,65 @@ +{ lib, stdenv, fetchFromGitHub, rustPlatform, napi-rs-cli, nodejs, libiconv }: + +stdenv.mkDerivation rec { + pname = "matrix-sdk-crypto-nodejs"; + version = "0.1.0-beta.2"; + + src = fetchFromGitHub { + owner = "matrix-org"; + repo = "matrix-rust-sdk"; + rev = "${pname}-v${version}"; + hash = "sha256-E++0tm/2d8/3zAXwovJ71uF2sxDORWyJNnA3e1Q3NLA="; + }; + + 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 + ]; + + cargoDeps = rustPlatform.fetchCargoTarball { + inherit src patches; + name = "${pname}-${version}"; + hash = "sha256-G2Um7vHinOuOx9U2BH14LAx+s/0Sxtlc9Nz6nPJfmU8="; + }; + + postPatch = '' + cd bindings/${pname} + ''; + + nativeBuildInputs = [ + rustPlatform.cargoSetupHook + rustPlatform.rust.cargo + rustPlatform.rust.rustc + napi-rs-cli + nodejs + ]; + + buildInputs = lib.optionals stdenv.isDarwin [ libiconv ]; + + buildPhase = '' + runHook preBuild + + npm run release-build --offline + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + local -r outPath="$out/lib/node_modules/@matrix-org/${pname}" + mkdir -p "$outPath" + cp package.json index.js index.d.ts matrix-sdk-crypto.*.node "$outPath" + + runHook postInstall + ''; + + meta = with lib; { + description = "A no-network-IO implementation of a state machine that handles E2EE for Matrix clients"; + homepage = "https://github.com/matrix-org/matrix-rust-sdk/tree/${src.rev}/bindings/matrix-sdk-crypto-nodejs"; + license = licenses.asl20; + maintainers = with maintainers; [ winter ]; + inherit (nodejs.meta) platforms; + }; +} diff --git a/pkgs/development/libraries/matrix-sdk-crypto-nodejs/remove-duplicate-dependency.patch b/pkgs/development/libraries/matrix-sdk-crypto-nodejs/remove-duplicate-dependency.patch new file mode 100644 index 0000000000000..0b1ddabcede47 --- /dev/null +++ b/pkgs/development/libraries/matrix-sdk-crypto-nodejs/remove-duplicate-dependency.patch @@ -0,0 +1,47 @@ +diff --git a/Cargo.lock b/Cargo.lock +index 2ddfdd0..3fcca5f 100644 +--- a/Cargo.lock ++++ b/Cargo.lock +@@ -1985,20 +1985,6 @@ version = "0.3.3" + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + +-[[package]] +-name = "indexed_db_futures" +-version = "0.2.3" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "d26ac735f676c52305becf53264b91cea9866a8de61ccbf464405b377b9cbca9" +-dependencies = [ +- "cfg-if", +- "js-sys", +- "uuid 0.8.2", +- "wasm-bindgen", +- "wasm-bindgen-futures", +- "web-sys", +-] +- + [[package]] + name = "indexed_db_futures" + version = "0.2.3" +@@ -2558,8 +2544,7 @@ dependencies = [ + "derive_builder", + "futures-util", + "getrandom 0.2.7", +- "indexed_db_futures 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +- "indexed_db_futures 0.2.3 (git+https://github.com/Hywan/rust-indexed-db?branch=feat-factory-nodejs)", ++ "indexed_db_futures", + "js-sys", + "matrix-sdk-base", + "matrix-sdk-common", +diff --git a/crates/matrix-sdk-indexeddb/Cargo.toml b/crates/matrix-sdk-indexeddb/Cargo.toml +index 7f23dfc..c57e29a 100644 +--- a/crates/matrix-sdk-indexeddb/Cargo.toml ++++ b/crates/matrix-sdk-indexeddb/Cargo.toml +@@ -30,7 +30,6 @@ js-sys = { version = "0.3.58" } + matrix-sdk-base = { version = "0.6.0", path = "../matrix-sdk-base", features = ["js"] } + matrix-sdk-crypto = { version = "0.6.0", path = "../matrix-sdk-crypto", features = ["js"], optional = true } + matrix-sdk-store-encryption = { version = "0.2.0", path = "../matrix-sdk-store-encryption" } +-indexed_db_futures = "0.2.3" + indexed_db_futures_nodejs = { package = "indexed_db_futures", git = "https://github.com/Hywan/rust-indexed-db", branch = "feat-factory-nodejs", optional = true } + ruma = "0.7.0" + serde = "1.0.136" diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 69b73a4169a8c..5b2103b4b3d0e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8941,6 +8941,8 @@ with pkgs; sasl = gsasl; }; + matrix-sdk-crypto-nodejs = callPackage ../development/libraries/matrix-sdk-crypto-nodejs { }; + email = callPackage ../tools/networking/email { }; maim = callPackage ../tools/graphics/maim {};