about summary refs log tree commit diff
path: root/pkgs/development/web/edge-runtime
diff options
context:
space:
mode:
authorhappysalada <raphael@megzari.com>2023-07-13 19:12:01 +0800
committerYt <happysalada@tuta.io>2023-07-14 11:26:32 +0800
commitcb697b86b1513dc02b6441d0f63dcb5437f4d243 (patch)
treeb1b63c243d557aa6ea1b00428d8d35b219f45720 /pkgs/development/web/edge-runtime
parentc625352b5326f9b52d20b2a6c6d9bd1c5aa6bfe3 (diff)
edge-runtime: init at 1.6.7
Diffstat (limited to 'pkgs/development/web/edge-runtime')
-rw-r--r--pkgs/development/web/edge-runtime/default.nix72
-rw-r--r--pkgs/development/web/edge-runtime/librusty_v8.nix20
2 files changed, 92 insertions, 0 deletions
diff --git a/pkgs/development/web/edge-runtime/default.nix b/pkgs/development/web/edge-runtime/default.nix
new file mode 100644
index 0000000000000..644349697c854
--- /dev/null
+++ b/pkgs/development/web/edge-runtime/default.nix
@@ -0,0 +1,72 @@
+{ stdenv
+, lib
+, callPackage
+, fetchFromGitHub
+, rustPlatform
+, nix-update-script
+, darwin
+, openssl
+, pkg-config
+}:
+
+let
+  pname = "edge-runtime";
+  version = "1.6.7";
+in
+rustPlatform.buildRustPackage {
+  inherit pname version;
+
+  src = fetchFromGitHub {
+    owner = "supabase";
+    repo = pname;
+    rev = "v${version}";
+    hash = "sha256-Jq9UXFgbTDKe1AWyg4fxn62ODqWu0AUqzlUOo+JUYpo=";
+    fetchSubmodules = true;
+  };
+
+  cargoHash = "sha256-fOqo9aPgpW6oAEHtZIE7iHjTIRrgDPbdSFBaq4s0r94=";
+
+  nativeBuildInputs = [ pkg-config rustPlatform.bindgenHook ];
+
+  buildInputs = lib.optionals stdenv.isLinux [ openssl ]
+    ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Security CoreFoundation ]);
+
+  # The v8 package will try to download a `librusty_v8.a` release at build time to our read-only filesystem
+  # To avoid this we pre-download the file and export it via RUSTY_V8_ARCHIVE
+  RUSTY_V8_ARCHIVE = callPackage ./librusty_v8.nix { };
+
+  passthru.updateScript = nix-update-script { };
+
+  preCheck = ''
+    export HOME=$(mktemp -d)
+  '';
+
+  checkFlags = [
+    # tries to make a network access
+    "--skip=deno_runtime::test::test_main_rt_fs"
+    "--skip=deno_runtime::test::test_main_runtime_creation"
+    "--skip=deno_runtime::test::test_os_env_vars"
+    "--skip=deno_runtime::test::test_os_ops"
+    "--skip=deno_runtime::test::test_user_runtime_creation"
+    "--skip=test_custom_readable_stream_response"
+    "--skip=test_import_map_file_path"
+    "--skip=test_import_map_inline"
+    "--skip=test_main_worker_options_request"
+    "--skip=test_main_worker_post_request"
+    "--skip=test_null_body_with_204_status"
+    "--skip=test_null_body_with_204_status_post"
+    "--skip=test_file_upload"
+    "--skip=test_oak_server"
+    "--skip=test_tls_throw_invalid_data"
+    "--skip=test_user_worker_json_imports"
+    "--skip=node::analyze::tests::test_esm_code_with_node_globals"
+    "--skip=node::analyze::tests::test_esm_code_with_node_globals_with_shebang"
+  ];
+
+  meta = with lib; {
+    description = "A server based on Deno runtime, capable of running JavaScript, TypeScript, and WASM services";
+    homepage = "https://github.com/supabase/edge-runtime";
+    license = licenses.mit;
+    maintainers = with maintainers; [ happysalada ];
+  };
+}
diff --git a/pkgs/development/web/edge-runtime/librusty_v8.nix b/pkgs/development/web/edge-runtime/librusty_v8.nix
new file mode 100644
index 0000000000000..30f6aebc2960f
--- /dev/null
+++ b/pkgs/development/web/edge-runtime/librusty_v8.nix
@@ -0,0 +1,20 @@
+{ rust, stdenv, fetchurl }:
+
+let
+  arch = rust.toRustTarget stdenv.hostPlatform;
+  fetch_librusty_v8 = args: fetchurl {
+    name = "librusty_v8-${args.version}";
+    url = "https://github.com/denoland/rusty_v8/releases/download/v${args.version}/librusty_v8_release_${arch}.a";
+    sha256 = args.shas.${stdenv.hostPlatform.system};
+    meta = { inherit (args) version; };
+  };
+in
+fetch_librusty_v8 {
+  version = "0.68.0";
+  shas = {
+    x86_64-linux = "sha256-yq7YPD2TM6Uw0EvCqIsZ/lbE1RLgIg7a42qDVrr5fX4=";
+    aarch64-linux = "sha256-uZFm3hAeyEUUXqRJFLM3OBVfglH3AecjFKVgeJZu3L0=";
+    x86_64-darwin = "sha256-YkxoggK0I4rT/KNJ30StDPLUc02Mdjwal3JH+s/YTQo=";
+    aarch64-darwin = "sha256-aXE7W3sSzbhvC661BYTTHyHlihmVVtFSv85nSjGOLkU=";
+  };
+}