5
5
buildGoModule ,
6
6
autoPatchelfHook ,
7
7
} :
8
+ let
9
+ wasmvmLib = if stdenv . isLinux then "libwasmvm.x86_64.so"
10
+ else if stdenv . isDarwin then "libwasmvm.dylib"
11
+ else throw "platform not supported" ;
12
+ in
8
13
buildGoModule rec {
9
14
pname = "wasmd" ;
10
15
version = "0.14.99" ;
@@ -19,21 +24,33 @@ buildGoModule rec {
19
24
20
25
subPackages = [ "cmd/wasmd" ] ;
21
26
22
- buildInputs = [ autoPatchelfHook ] ;
27
+ buildInputs = [ ] ++ lib . optional stdenv . isLinux [ autoPatchelfHook ] ;
23
28
24
29
postBuild = ''
25
30
mkdir -p "$out/lib"
26
31
# TODO: The correct binary below should depend on the current OS and CPU
27
- cp "$GOPATH/pkg/mod/github.com/!cosm!wasm/[email protected] /api/libwasmvm.x86_64.so " "$out/lib"
32
+ cp "$GOPATH/pkg/mod/github.com/!cosm!wasm/[email protected] /api/${ wasmvmLib } " "$out/lib"
28
33
'' ;
29
34
30
- postInstall = ''
35
+ postInstall = if stdenv . isLinux then ''
31
36
addAutoPatchelfSearchPath "$out/lib"
32
37
# TODO: autoPatchElf is Linux-specific. We need a cross-platform solution
33
38
autoPatchelf -- "$out/bin"
34
- '' ;
39
+ '' else
40
+ # TODO
41
+ # The package is still not working because we are missing the equivalent
42
+ # of autopatchelf for macOS. The "libwasmvm.dylib" is currently distributed
43
+ # as a pre-built binary by the wasmd team (it's stored in git). This leads
44
+ # to the final wasmd binary having a `rpath` which cannot be satisfied at
45
+ # run-time with Nix.
46
+ "" ;
47
+
48
+ vendorSha256 = if stdenv . isLinux then
49
+ "sha256-4vW1+vGOwbaE6fVXtHjKMheX9UpiY7WVh7QCC57QQUM="
50
+ else if stdenv . isDarwin then
51
+ "sha256-vACKDwUP52iSjb0DC+dIuNrOeBMLnKBDYsNpQrq3IqI="
52
+ else "" ;
35
53
36
- vendorSha256 = "sha256-4vW1+vGOwbaE6fVXtHjKMheX9UpiY7WVh7QCC57QQUM=" ;
37
54
doCheck = false ;
38
55
meta = with lib ; {
39
56
description = "Basic cosmos-sdk app with web assembly smart contracts" ;
0 commit comments