Skip to content

Commit

Permalink
Problem: solomachine nix package don't support more platforms (#1107)
Browse files Browse the repository at this point in the history
* Problem: solomachine nix package don't support more platforms

Solution:
- build on the fly

* fix solo machine path

* isort

* nix fmt
  • Loading branch information
yihuang authored Feb 4, 2025
1 parent 529aaec commit 0fc2416
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 40 deletions.
36 changes: 0 additions & 36 deletions integration_tests/install_solo_machine.nix

This file was deleted.

1 change: 0 additions & 1 deletion integration_tests/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ pkgs.mkShell {
];
shellHook = ''
export PYTHONPATH=$PWD/pystarport/proto_python/:$PYTHONPATH
export SOLO_MACHINE_HOME="${pkgs.solomachine}/solomachine"
mkdir -p "$PWD/coverage"
export GOCOVERDIR="$PWD/coverage"
'';
Expand Down
5 changes: 3 additions & 2 deletions integration_tests/test_solo_machine.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
import platform
import shutil
from pathlib import Path

import pytest
Expand Down Expand Up @@ -52,8 +53,8 @@ def __init__(
self.chain_id = chain_id
self.grpc_port = ports.grpc_port(base_port)
self.rpc_port = ports.rpc_port(base_port)
self.solomachine_home = os.path.join(os.environ["SOLO_MACHINE_HOME"])
self.bin_file = os.path.join(self.solomachine_home, "solo-machine")
self.solomachine_home = Path(shutil.which("solo-machine")).parent.parent / "lib"
self.bin_file = "solo-machine"
self.mnemonic = mnemonic

os_platform = platform.system()
Expand Down
2 changes: 1 addition & 1 deletion nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import sources.nixpkgs {
doCheck = false;
};
hermes = pkgs.callPackage ./hermes.nix { src = sources.ibc-rs; };
solomachine = pkgs.callPackage ./solomachine.nix { };
})
(import "${sources.poetry2nix}/overlay.nix")
(import "${sources.gomod2nix}/overlay.nix")
Expand All @@ -27,7 +28,6 @@ import sources.nixpkgs {
find . -name "*.nix" -type f | xargs ${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt --check || EXIT_STATUS=$?
exit $EXIT_STATUS
'';
solomachine = pkgs.callPackage ../integration_tests/install_solo_machine.nix { };
chain-maind-zemu = pkgs.callPackage ../. {
ledger_zemu = true;
};
Expand Down
29 changes: 29 additions & 0 deletions nix/solomachine.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{ fetchFromGitHub
, lib
, stdenv
, darwin
, rustPlatform
, protobuf
, rustfmt
,
}:
rustPlatform.buildRustPackage rec {
pname = "ibc-solo-machine";
version = "0.1.4";

src = fetchFromGitHub {
owner = "crypto-com";
repo = pname;
rev = "v${version}";
sha256 = "sha256-+jfRbPm31/pBuseUS89cuYSAPw2l/509MVTaUcuyaGY=";
};

cargoSha256 = "sha256-9Mx70yBoNy711PFC5y2VoXD3kqmcMvDsjP9AaC1VfCM=";
cargoBuildFlags = "-p solo-machine -p mnemonic-signer";
nativeBuildInputs = [
protobuf
rustfmt
];
buildInputs = lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.SystemConfiguration ];
doCheck = false;
}

0 comments on commit 0fc2416

Please sign in to comment.