deno: make it easier to override librusty_v8

This commit is contained in:
06kellyjac 2021-03-12 11:25:34 +00:00
parent dd50d1df59
commit 9611f03177
3 changed files with 27 additions and 26 deletions

View File

@ -1,5 +1,6 @@
{ stdenv
, lib
, callPackage
, fetchurl
, fetchFromGitHub
, rust
@ -7,6 +8,7 @@
, installShellFiles
, Security
, CoreServices
, librusty_v8 ? callPackage ./librusty_v8.nix { }
}:
rustPlatform.buildRustPackage rec {
@ -29,25 +31,16 @@ rustPlatform.buildRustPackage rec {
# The rusty_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 place it in the locations it will require it in advance
preBuild =
let
inherit (import ./deps.nix { }) librusty_v8;
arch = rust.toRustTarget stdenv.hostPlatform;
librusty_v8_release = fetchurl {
url = "https://github.com/denoland/rusty_v8/releases/download/v${librusty_v8.version}/librusty_v8_release_${arch}.a";
sha256 = librusty_v8.sha256s.${stdenv.hostPlatform.system};
meta = { inherit (librusty_v8) version; };
};
in
let arch = rust.toRustTarget stdenv.hostPlatform; in
''
_rusty_v8_setup() {
_librusty_v8_setup() {
for v in "$@"; do
dir="target/$v/gn_out/obj"
mkdir -p "$dir" && cp "${librusty_v8_release}" "$dir/librusty_v8.a"
install -D ${librusty_v8} "target/$v/gn_out/obj/librusty_v8.a"
done
}
# Copy over the `librusty_v8.a` file inside target/XYZ/gn_out/obj, symlink not allowed
_rusty_v8_setup "debug" "release" "${arch}/release"
_librusty_v8_setup "debug" "release" "${arch}/release"
'';
# Tests have some inconsistencies between runs with output integration tests

View File

@ -1,13 +0,0 @@
# auto-generated file -- DO NOT EDIT!
{}:
rec {
librusty_v8 = {
version = "0.20.0";
sha256s = {
x86_64-linux = "1y0av2hghdvk2qv8kgw29x833wy31i89z7z6hw4jd1y21ihqsdd5";
aarch64-linux = "0726ay48w74y79j892is8qxx0kg3m35lmbniwcgy37idxm06vx28";
x86_64-darwin = "0gmfdmd5dvxh5xyxsq3nk8fpvdmpczq7nmj1b2zsakl8v3j14jck";
aarch64-darwin = "1zw3pxp13s38wspv5lwcns02wzrqagay9zjxj2wiygfzzr5b2c88";
};
};
}

View File

@ -0,0 +1,21 @@
# auto-generated file -- DO NOT EDIT!
{ 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.20.0";
shas = {
x86_64-linux = "sha256-pTWNYQzChyYJh+afn1AMw/MxUE+Cv4k2FnM3+KDYCvg=";
aarch64-linux = "sha256-SPRtQO0tnuEf49GuSsuo403QO0Y6ioRkOp4cjohXRhw=";
x86_64-darwin = "sha256-k0kS5NiITqW/WEFWe/Bnt7Z9HZp2YN19L7DvVlptrj4=";
aarch64-darwin = "sha256-CDGxSv7fPR+5kF3+5NVTOH8ugLaM07Kv5mjoEW6/g/8=";
};
}