Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packaging/dependencies.nix
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,6 @@ scope: {
buildPhase = lib.replaceStrings [ "--without-python" ] [ "" ] old.buildPhase;
installPhase = lib.replaceStrings [ "--without-python" ] [ "" ] old.installPhase;
});

wasmtime = pkgs.callPackage ./wasmtime.nix { };
}
101 changes: 101 additions & 0 deletions packaging/wasmtime.nix
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a copyright notice that points back to nixpkgs, since this is a verbatim copy of the package definition from there.

Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
lib,
stdenv,
rust_1_89,
fetchFromGitHub,
buildPackages,
cmake,
installShellFiles,
nix-update-script,
enableShared ? !stdenv.hostPlatform.isStatic,
enableStatic ? stdenv.hostPlatform.isStatic,
}:
rust_1_89.packages.stable.rustPlatform.buildRustPackage (finalAttrs: {
pname = "wasmtime";
version = "40.0.0";

src = fetchFromGitHub {
owner = "bytecodealliance";
repo = "wasmtime";
tag = "v${finalAttrs.version}";
hash = "sha256-d5j+QSEWIVwVRMT/QGc6x3cVBTFZBpoxiBagmpLV1e8=";
fetchSubmodules = true;
};

# Disable cargo-auditable until https://github.com/rust-secure-code/cargo-auditable/issues/124 is solved.
auditable = false;

cargoHash = "sha256-PIUJHkeGi8gao7n+SLzcxNYTl2KxKiwJZPW+sFYf0AY=";
cargoBuildFlags = [
"--package"
"wasmtime-c-api"
"--no-default-features"
"--features cranelift,wasi,pooling-allocator,wat,demangle,gc-null"
];

outputs = [
"out"
"lib"
];

nativeBuildInputs = [
cmake
installShellFiles
];

doCheck =
with stdenv.buildPlatform;
# SIMD tests are only executed on platforms that support all
# required processor features (e.g. SSE3, SSSE3 and SSE4.1 on x86_64):
# https://github.com/bytecodealliance/wasmtime/blob/v9.0.0/cranelift/codegen/src/isa/x64/mod.rs#L220
(isx86_64 -> sse3Support && ssse3Support && sse4_1Support)
&&
# The dependency `wasi-preview1-component-adapter` fails to build because of:
# error: linker `rust-lld` not found
!isAarch64;

postInstall =
let
inherit (stdenv.hostPlatform.rust) cargoShortTarget;
in
''
moveToOutput lib $lib
${lib.optionalString (!enableShared) "rm -f $lib/lib/*.so{,.*}"}
${lib.optionalString (!enableStatic) "rm -f $lib/lib/*.a"}

# copy the build.rs generated c-api headers
# https://github.com/rust-lang/cargo/issues/9661
mkdir -p $out
cp -r target/${cargoShortTarget}/release/build/wasmtime-c-api-impl-*/out/include $out/include
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
install_name_tool -id \
$lib/lib/libwasmtime.dylib \
$lib/lib/libwasmtime.dylib
'';

passthru = {
updateScript = nix-update-script {
extraArgs = [
"--version-regex"
"^v(\\d+\\.\\d+\\.\\d+)$"
];
};
};

meta = {
description = "Standalone JIT-style runtime for WebAssembly, using Cranelift";
homepage = "https://wasmtime.dev/";
license = [
lib.licenses.asl20
lib.licenses.llvm-exception
];
mainProgram = "wasmtime";
maintainers = with lib.maintainers; [
ereslibre
nekowinston
];
platforms = lib.platforms.unix;
changelog = "https://github.com/bytecodealliance/wasmtime/blob/v${finalAttrs.version}/RELEASES.md";
};
})
2 changes: 1 addition & 1 deletion src/libexpr/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ this_library = library(
soversion : nix_soversion,
dependencies : deps_public + deps_private + deps_other,
include_directories : include_dirs,
link_args : linker_export_flags,
link_args : linker_export_flags + [ '-lwasmtime' ],
link_whole : [ parser_library ],
prelink : true, # For C++ static initializers
install : true,
Expand Down
2 changes: 2 additions & 0 deletions src/libexpr/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
boehmgc,
nlohmann_json,
toml11,
wasmtime,

# Configuration Options

Expand Down Expand Up @@ -64,6 +65,7 @@ mkMesonLibrary (finalAttrs: {

buildInputs = [
toml11
wasmtime
];

propagatedBuildInputs = [
Expand Down
2 changes: 1 addition & 1 deletion src/libexpr/primops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ StringMap EvalState::realiseContext(const NixStringContext & context, StorePathS
return res;
}

static SourcePath realisePath(
SourcePath realisePath(
EvalState & state,
const PosIdx pos,
Value & v,
Expand Down
1 change: 1 addition & 0 deletions src/libexpr/primops/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ sources += files(
'fetchMercurial.cc',
'fetchTree.cc',
'fromTOML.cc',
'wasm.cc',
)
Loading