forked from WasmEdge/WasmEdge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
85 lines (78 loc) · 2.63 KB
/
flake.nix
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
80
81
82
83
84
85
{
inputs = {
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, rust-overlay, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
rust = pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rust-src" ];
targets = [ "wasm32-wasi" "wasm32-unknown-unknown" ];
};
llvmPackages = pkgs.llvmPackages_16;
runRustSysTest = pkgs.writeShellScriptBin "run-rust-sys-test" ''
cd bindings/rust/
export WASMEDGE_DIR="$(pwd)/../../"
export WASMEDGE_BUILD_DIR="$(pwd)/../../build"
export LD_LIBRARY_PATH="$(pwd)/../../build/lib/api"
cargo test -p wasmedge-sys --examples -- --nocapture
'';
runRustSysExample = pkgs.writeShellScriptBin "run-rust-sys-example" ''
cd bindings/rust/
export WASMEDGE_DIR="$(pwd)/../../"
export WASMEDGE_BUILD_DIR="$(pwd)/../../build"
export LD_LIBRARY_PATH="$(pwd)/../../build/lib/api"
cargo run -p wasmedge-sys --example $1
'';
wasmedge = pkgs.stdenv.mkDerivation {
name = "wasmedge";
version = "0.12.1";
src = ./.;
buildInputs = with pkgs; [
cmake
llvmPackages.clang-unwrapped
llvmPackages.lld
llvmPackages.llvm
openssl
pkg-config
libxml2
spdlog
] ++ pkgs.lib.optionals (system == "x86_64-darwin" || system == "aarch64-darwin") [
pkgs.darwin.apple_sdk.frameworks.Foundation
];
configurePhase = ''
cmake -Bbuild \
-DCMAKE_BUILD_TYPE=Debug \
-DWASMEDGE_BUILD_PLUGINS=OFF \
-DWASMEDGE_BUILD_TESTS=OFF \
-DWASMEDGE_BUILD_AOT_RUNTIME=ON \
.
'';
buildPhase = ''
cmake --build build -j
'';
installPhase = ''
cd build
cmake --install . --prefix $out
'';
};
in with pkgs; rec {
packages = { wasmedge = wasmedge; };
packages.default = packages.wasmedge;
devShells.default = mkShell {
buildInputs = [
wasmedge
ninja
rust
gcovr
runRustSysTest
runRustSysExample
];
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
};
});
}