Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions packages/wasmd/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
buildGoModule,
autoPatchelfHook,
}:
let
wasmvmLib = if stdenv.isLinux then "libwasmvm.x86_64.so"
else if stdenv.isDarwin then "libwasmvm.dylib"
else throw "platform not supported";
in
buildGoModule rec {
pname = "wasmd";
version = "0.14.99";
Expand All @@ -19,21 +24,33 @@ buildGoModule rec {

subPackages = ["cmd/wasmd"];

buildInputs = [autoPatchelfHook];
buildInputs = [] ++ lib.optional stdenv.isLinux [autoPatchelfHook];

postBuild = ''
mkdir -p "$out/lib"
# TODO: The correct binary below should depend on the current OS and CPU
cp "$GOPATH/pkg/mod/github.com/!cosm!wasm/[email protected]/api/libwasmvm.x86_64.so" "$out/lib"
cp "$GOPATH/pkg/mod/github.com/!cosm!wasm/[email protected]/api/${wasmvmLib}" "$out/lib"
'';

postInstall = ''
postInstall = if stdenv.isLinux then ''
addAutoPatchelfSearchPath "$out/lib"
# TODO: autoPatchElf is Linux-specific. We need a cross-platform solution
autoPatchelf -- "$out/bin"
'';
'' else
# TODO
# The package is still not working because we are missing the equivalent
# of autopatchelf for macOS. The "libwasmvm.dylib" is currently distributed
# as a pre-built binary by the wasmd team (it's stored in git). This leads
# to the final wasmd binary having a `rpath` which cannot be satisfied at
# run-time with Nix.
"";

vendorSha256 = if stdenv.isLinux then
"sha256-4vW1+vGOwbaE6fVXtHjKMheX9UpiY7WVh7QCC57QQUM="
else if stdenv.isDarwin then
"sha256-vACKDwUP52iSjb0DC+dIuNrOeBMLnKBDYsNpQrq3IqI="
else "";

vendorSha256 = "sha256-4vW1+vGOwbaE6fVXtHjKMheX9UpiY7WVh7QCC57QQUM=";
doCheck = false;
meta = with lib; {
description = "Basic cosmos-sdk app with web assembly smart contracts";
Expand Down
2 changes: 1 addition & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ with pkgs;
# Packages defined in this repo
metacraft-labs.cosmos-theta-testnet
metacraft-labs.circom
metacraft-labs.wasmd
metacraft-labs.circ
]
++ lib.optionals (!stdenv.isDarwin) [
# Solana is still not compatible with macOS on M1
metacraft-labs.solana
metacraft-labs.wasmd
];

shellHook = ''
Expand Down