forked from crypto-org-chain/cronos
-
Notifications
You must be signed in to change notification settings - Fork 2
/
default.nix
97 lines (92 loc) · 2.84 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
{
lib,
stdenv,
buildGoApplication,
nix-gitignore,
buildPackages,
coverage ? false, # https://tip.golang.org/doc/go1.20#cover
rocksdb,
network ? "mainnet", # mainnet|testnet
rev ? "dirty",
static ? stdenv.hostPlatform.isStatic,
nativeByteOrder ? true, # nativeByteOrder mode will panic on big endian machines
}:
let
version = "v0.0.2";
pname = "supernovad";
tags = [ "ledger" "netgo" network "rocksdb" "grocksdb_no_link" "pebbledb" "objstore" ] ++ lib.optionals nativeByteOrder [ "nativebyteorder" ];
ldflags = lib.concatStringsSep "\n" ([
"-X github.com/cosmos/cosmos-sdk/version.Name=supernova"
"-X github.com/cosmos/cosmos-sdk/version.AppName=${pname}"
"-X github.com/cosmos/cosmos-sdk/version.Version=${version}"
"-X github.com/cosmos/cosmos-sdk/version.BuildTags=${lib.concatStringsSep "," tags}"
"-X github.com/cosmos/cosmos-sdk/version.Commit=${rev}"
]);
buildInputs = [ rocksdb ];
isWindows = stdenv.hostPlatform.isWindows;
isLinux = stdenv.hostPlatform.isLinux;
isDarwin = stdenv.isDarwin;
in
buildGoApplication rec {
inherit
pname
version
buildInputs
tags
ldflags
;
src = (
nix-gitignore.gitignoreSourcePure [
"/*" # ignore all, then add whitelists
"!/x/"
"!/app/"
"!/cmd/"
"!/client/"
"!/versiondb/"
"!/memiavl/"
"!/store/"
"!go.mod"
"!go.sum"
"!gomod2nix.toml"
] ./.
);
modules = ./gomod2nix.toml;
pwd = src; # needed to support replace
subPackages = [ "cmd/cronosd" ];
buildFlags = lib.optionalString coverage "-cover";
CGO_ENABLED = "1";
CGO_LDFLAGS = lib.optionalString (rocksdb != null) (
if static then
"-lrocksdb -pthread -lstdc++ -ldl -lzstd -lsnappy -llz4 -lbz2 -lz"
else if isWindows then
"-lrocksdb-shared"
else
"-lrocksdb -pthread -lstdc++ -ldl"
);
postFixup = ''
# Rename the binary to supernovad if on Darwin
${lib.optionalString (isDarwin) ''
mv $out/bin/cronosd $out/bin/supernovad
''}
# Adjust the install_name_tool command if on Darwin
${lib.optionalString (isDarwin && rocksdb != null) ''
${stdenv.cc.bintools.targetPrefix}install_name_tool -change "@rpath/librocksdb.9.dylib" "${rocksdb}/lib/librocksdb.dylib" $out/bin/supernovad
''}
# Rename the binary to supernovad if on Windows
${lib.optionalString (isWindows) ''
mv $out/bin/cronosd.exe $out/bin/supernovad.exe
''}
# Rename the binary to supernovad if on Linux
${lib.optionalString (isLinux) ''
mv $out/bin/cronosd $out/bin/supernovad
''}
'';
doCheck = false;
meta = with lib; {
description = "Supernova EVM extension-chain";
homepage = "https://cronos.org/";
license = licenses.asl20;
mainProgram = "supernovad" + stdenv.hostPlatform.extensions.executable;
platforms = platforms.all;
};
}