1+ {
2+ lib ,
3+ stdenv ,
4+ buildGo123Module ,
5+ fetchFromGitHub ,
6+ rev ? "dirty" ,
7+ nativeByteOrder ? true , # nativeByteOrder mode will panic on big endian machines
8+ fetchurl ,
9+ pkgsStatic ,
10+ } :
11+ let
12+ version = "v0.5.0" ;
13+ pname = "evmd" ;
14+
15+ # Use static packages for Linux to ensure musl compatibility
16+ buildPackages = if stdenv . isLinux then pkgsStatic else { inherit stdenv buildGo123Module ; } ;
17+ buildStdenv = buildPackages . stdenv ;
18+ buildGo123Module' = if stdenv . isLinux then buildPackages . buildGo123Module else buildGo123Module ;
19+
20+ tags =
21+ [
22+ "ledger"
23+ "netgo"
24+ "osusergo"
25+ "pebbledb"
26+ ]
27+ ++ lib . optionals nativeByteOrder [ "nativebyteorder" ]
28+ ++ lib . optionals buildStdenv . isLinux [ "muslc" ] ;
29+
30+ ldflags =
31+ [
32+ "-X github.com/cosmos/cosmos-sdk/version.Name=evmd"
33+ "-X github.com/cosmos/cosmos-sdk/version.AppName=${ pname } "
34+ "-X github.com/cosmos/cosmos-sdk/version.Version=${ version } "
35+ "-X github.com/cosmos/cosmos-sdk/version.BuildTags=${ lib . concatStringsSep "," tags } "
36+ "-X github.com/cosmos/cosmos-sdk/version.Commit=${ rev } "
37+ ]
38+ ++ [
39+ "-w"
40+ "-s"
41+ "-linkmode=external"
42+ ]
43+ ++ lib . optionals buildStdenv . isLinux [
44+ "-extldflags '-static -lm'"
45+ ] ;
46+
47+ in
48+ buildGo123Module' rec {
49+ inherit
50+ pname
51+ version
52+ tags
53+ ldflags
54+ ;
55+ stdenv = buildStdenv ;
56+ src = fetchFromGitHub {
57+ owner = "cosmos" ;
58+ repo = "evm" ;
59+ rev = "733ea6190eb1be15ed1276ab54f4a8b511ff1c66" ;
60+ hash = "sha256-mZQhW6CpIUGPj3WWw5v2Zeov1mMnKx+ZqNX3YcFOcVE=" ;
61+ } ;
62+
63+ vendorHash = "sha256-IDJHj2e2LBMe0BtwduG7/wLM/C2rRQyIUpbMawJAilk=" ;
64+ proxyVendor = true ;
65+ sourceRoot = "source/evmd" ;
66+ subPackages = [ "cmd/evmd" ] ;
67+ CGO_ENABLED = "1" ;
68+
69+ preBuild = ''
70+ mkdir -p $TMPDIR/lib
71+ export CGO_LDFLAGS="-L$TMPDIR/lib $CGO_LDFLAGS"
72+ '' ;
73+
74+ doCheck = false ;
75+ meta = with lib ; {
76+ description = "An EVM compatible framework for blockchain development with the Cosmos SDK" ;
77+ homepage = "https://github.com/cosmos/evm" ;
78+ license = licenses . asl20 ;
79+ mainProgram = "evmd" + buildStdenv . hostPlatform . extensions . executable ;
80+ platforms = platforms . all ;
81+ } ;
82+ }
0 commit comments