From cb697b86b1513dc02b6441d0f63dcb5437f4d243 Mon Sep 17 00:00:00 2001 From: happysalada Date: Thu, 13 Jul 2023 19:12:01 +0800 Subject: [PATCH] edge-runtime: init at 1.6.7 --- pkgs/development/web/edge-runtime/default.nix | 72 +++++++++++++++++++ .../web/edge-runtime/librusty_v8.nix | 20 ++++++ pkgs/top-level/all-packages.nix | 2 + 3 files changed, 94 insertions(+) create mode 100644 pkgs/development/web/edge-runtime/default.nix create mode 100644 pkgs/development/web/edge-runtime/librusty_v8.nix diff --git a/pkgs/development/web/edge-runtime/default.nix b/pkgs/development/web/edge-runtime/default.nix new file mode 100644 index 000000000000..644349697c85 --- /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 000000000000..30f6aebc2960 --- /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="; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 4b5814767abb..41f34b6f1fce 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -573,6 +573,8 @@ with pkgs; inherit (darwin.apple_sdk.frameworks) CoreServices Security; }; + edge-runtime = callPackage ../development/web/edge-runtime { }; + efficient-compression-tool = callPackage ../tools/compression/efficient-compression-tool { }; eludris = callPackage ../tools/misc/eludris {