summaryrefslogtreecommitdiff
path: root/pkgs/development/tools/wasmedge/default.nix
blob: e416f563788f5942442900f7ccd3b2eccdd9dfda (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{
  lib,
  stdenv,
  fetchFromGitHub,
  llvmPackages_17,
  boost,
  cmake,
  spdlog,
  libxml2,
  libffi,
  Foundation,
  testers,
}:

let
  # The supported version is found in the changelog, the documentation does indicate a minimum version but not a maximum.
  # The project is also using a `flake.nix` so we can retrieve the used llvm version with:
  #
  # ```shell
  # nix eval --inputs-from .# nixpkgs#llvmPackages.libllvm.version
  # ```
  #
  # > Where `.#` is the flake path were the repo `wasmedge` was cloned at the expected version.
  llvmPackages = llvmPackages_17;
in
llvmPackages.stdenv.mkDerivation (finalAttrs: {
  pname = "wasmedge";
  version = "0.14.1";

  src = fetchFromGitHub {
    owner = "WasmEdge";
    repo = "WasmEdge";
    rev = finalAttrs.version;
    sha256 = "sha256-70vvQGYcer3dosb1ulWO1F4xFwKwfo35l/TFSFa5idM=";
  };

  nativeBuildInputs = [
    cmake
    llvmPackages.lld
  ];

  buildInputs =
    [
      boost
      spdlog
      llvmPackages.llvm
      libxml2
      libffi
    ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      Foundation
    ];

  cmakeFlags =
    [
      "-DWASMEDGE_BUILD_TESTS=OFF" # Tests are downloaded using git
    ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      "-DWASMEDGE_FORCE_DISABLE_LTO=ON"
    ];

  postPatch = ''
    echo -n $version > VERSION
  '';

  passthru.tests = {
    version = testers.testVersion {
      package = finalAttrs.finalPackage;
    };
  };

  meta = with lib; {
    homepage = "https://wasmedge.org/";
    license = with licenses; [ asl20 ];
    description = "Lightweight, high-performance, and extensible WebAssembly runtime for cloud native, edge, and decentralized applications";
    maintainers = with maintainers; [ dit7ya ];
    platforms = platforms.all;
  };
})