1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 llvmPackages_17,
6 boost,
7 cmake,
8 spdlog,
9 libxml2,
10 libffi,
11 testers,
12}:
13
14let
15 # The supported version is found in the changelog, the documentation does indicate a minimum version but not a maximum.
16 # The project is also using a `flake.nix` so we can retrieve the used llvm version with:
17 #
18 # ```shell
19 # nix eval --inputs-from .# nixpkgs#llvmPackages.libllvm.version
20 # ```
21 #
22 # > Where `.#` is the flake path were the repo `wasmedge` was cloned at the expected version.
23 llvmPackages = llvmPackages_17;
24in
25llvmPackages.stdenv.mkDerivation (finalAttrs: {
26 pname = "wasmedge";
27 version = "0.14.1";
28
29 src = fetchFromGitHub {
30 owner = "WasmEdge";
31 repo = "WasmEdge";
32 rev = finalAttrs.version;
33 sha256 = "sha256-70vvQGYcer3dosb1ulWO1F4xFwKwfo35l/TFSFa5idM=";
34 };
35
36 nativeBuildInputs = [
37 cmake
38 llvmPackages.lld
39 ];
40
41 buildInputs = [
42 boost
43 spdlog
44 llvmPackages.llvm
45 libxml2
46 libffi
47 ];
48
49 cmakeFlags = [
50 "-DWASMEDGE_BUILD_TESTS=OFF" # Tests are downloaded using git
51 ]
52 ++ lib.optionals stdenv.hostPlatform.isDarwin [
53 "-DWASMEDGE_FORCE_DISABLE_LTO=ON"
54 ];
55
56 postPatch = ''
57 echo -n $version > VERSION
58 '';
59
60 passthru.tests = {
61 version = testers.testVersion {
62 package = finalAttrs.finalPackage;
63 };
64 };
65
66 meta = with lib; {
67 homepage = "https://wasmedge.org/";
68 license = with licenses; [ asl20 ];
69 description = "Lightweight, high-performance, and extensible WebAssembly runtime for cloud native, edge, and decentralized applications";
70 maintainers = with maintainers; [ dit7ya ];
71 platforms = platforms.all;
72 };
73})