Skip to content

Commit 4f304cd

Browse files
committed
Some progress towards enabling wasmd on macOS
1 parent 34b9e2c commit 4f304cd

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

packages/wasmd/default.nix

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
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
813
buildGoModule 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";

shell.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ with pkgs;
1212
# Packages defined in this repo
1313
metacraft-labs.cosmos-theta-testnet
1414
metacraft-labs.circom
15+
metacraft-labs.wasmd
1516
metacraft-labs.circ
1617
]
1718
++ lib.optionals (!stdenv.isDarwin) [
1819
# Solana is still not compatible with macOS on M1
1920
metacraft-labs.solana
20-
metacraft-labs.wasmd
2121
];
2222

2323
shellHook = ''

0 commit comments

Comments
 (0)