55 buildGoModule ,
66 autoPatchelfHook ,
77} :
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
813buildGoModule rec {
914 pname = "wasmd" ;
1015 version = "0.14.99" ;
@@ -19,21 +24,33 @@ buildGoModule rec {
1924
2025 subPackages = [ "cmd/wasmd" ] ;
2126
22- buildInputs = [ autoPatchelfHook ] ;
27+ buildInputs = [ ] ++ lib . optional stdenv . isLinux [ autoPatchelfHook ] ;
2328
2429 postBuild = ''
2530 mkdir -p "$out/lib"
2631 # 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" 2833 '' ;
2934
30- postInstall = ''
35+ postInstall = if stdenv . isLinux then ''
3136 addAutoPatchelfSearchPath "$out/lib"
3237 # TODO: autoPatchElf is Linux-specific. We need a cross-platform solution
3338 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 "" ;
3553
36- vendorSha256 = "sha256-4vW1+vGOwbaE6fVXtHjKMheX9UpiY7WVh7QCC57QQUM=" ;
3754 doCheck = false ;
3855 meta = with lib ; {
3956 description = "Basic cosmos-sdk app with web assembly smart contracts" ;
0 commit comments