Skip to content

Commit b058752

Browse files
committed
format
1 parent 0d9b969 commit b058752

21 files changed

+335
-624
lines changed

default.nix

Lines changed: 29 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
{
2-
lib,
3-
stdenv,
4-
buildGoApplication,
5-
nix-gitignore,
6-
buildPackages,
7-
coverage ? false, # https://tip.golang.org/doc/go1.20#cover
8-
rocksdb,
9-
network ? "mainnet", # mainnet|testnet
10-
rev ? "dirty",
11-
static ? stdenv.hostPlatform.isStatic,
12-
nativeByteOrder ? true, # nativeByteOrder mode will panic on big endian machines
1+
{ lib, stdenv, buildGoApplication, nix-gitignore, buildPackages
2+
, coverage ? false, # https://tip.golang.org/doc/go1.20#cover
3+
rocksdb, network ? "mainnet", # mainnet|testnet
4+
rev ? "dirty", static ? stdenv.hostPlatform.isStatic, nativeByteOrder ? true
5+
, # nativeByteOrder mode will panic on big endian machines
136
}:
147
let
158
version = "v1.4.0";
@@ -27,47 +20,38 @@ let
2720
"-X github.com/cosmos/cosmos-sdk/version.Name=cronos"
2821
"-X github.com/cosmos/cosmos-sdk/version.AppName=${pname}"
2922
"-X github.com/cosmos/cosmos-sdk/version.Version=${version}"
30-
"-X github.com/cosmos/cosmos-sdk/version.BuildTags=${lib.concatStringsSep "," tags}"
23+
"-X github.com/cosmos/cosmos-sdk/version.BuildTags=${
24+
lib.concatStringsSep "," tags
25+
}"
3126
"-X github.com/cosmos/cosmos-sdk/version.Commit=${rev}"
3227
]);
3328
buildInputs = [ rocksdb ];
34-
in
35-
buildGoApplication rec {
36-
inherit
37-
pname
38-
version
39-
buildInputs
40-
tags
41-
ldflags
42-
;
43-
src = (
44-
nix-gitignore.gitignoreSourcePure [
45-
"/*" # ignore all, then add whitelists
46-
"!/x/"
47-
"!/app/"
48-
"!/cmd/"
49-
"!/client/"
50-
"!/versiondb/"
51-
"!/memiavl/"
52-
"!/store/"
53-
"!go.mod"
54-
"!go.sum"
55-
"!gomod2nix.toml"
56-
] ./.
57-
);
29+
in buildGoApplication rec {
30+
inherit pname version buildInputs tags ldflags;
31+
src = (nix-gitignore.gitignoreSourcePure [
32+
"/*" # ignore all, then add whitelists
33+
"!/x/"
34+
"!/app/"
35+
"!/cmd/"
36+
"!/client/"
37+
"!/versiondb/"
38+
"!/memiavl/"
39+
"!/store/"
40+
"!go.mod"
41+
"!go.sum"
42+
"!gomod2nix.toml"
43+
] ./.);
5844
modules = ./gomod2nix.toml;
5945
pwd = src; # needed to support replace
6046
subPackages = [ "cmd/cronosd" ];
6147
buildFlags = lib.optionalString coverage "-cover";
6248
CGO_ENABLED = "1";
63-
CGO_LDFLAGS = lib.optionalString (rocksdb != null) (
64-
if static then
65-
"-lrocksdb -pthread -lstdc++ -ldl -lzstd -lsnappy -llz4 -lbz2 -lz"
66-
else if stdenv.hostPlatform.isWindows then
67-
"-lrocksdb-shared"
68-
else
69-
"-lrocksdb -pthread -lstdc++ -ldl"
70-
);
49+
CGO_LDFLAGS = lib.optionalString (rocksdb != null) (if static then
50+
"-lrocksdb -pthread -lstdc++ -ldl -lzstd -lsnappy -llz4 -lbz2 -lz"
51+
else if stdenv.hostPlatform.isWindows then
52+
"-lrocksdb-shared"
53+
else
54+
"-lrocksdb -pthread -lstdc++ -ldl");
7155

7256
postFixup = lib.optionalString (stdenv.isDarwin && rocksdb != null) ''
7357
${stdenv.cc.bintools.targetPrefix}install_name_tool -change "@rpath/librocksdb.8.dylib" "${rocksdb}/lib/librocksdb.dylib" $out/bin/cronosd

flake.nix

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,21 @@
1919
};
2020

2121
outputs =
22-
{
23-
self,
24-
nixpkgs,
25-
nix-bundle-exe,
26-
gomod2nix,
27-
flake-utils,
28-
poetry2nix,
29-
}:
22+
{ self, nixpkgs, nix-bundle-exe, gomod2nix, flake-utils, poetry2nix, }:
3023
let
3124
rev = self.shortRev or "dirty";
3225
mkApp = drv: {
3326
type = "app";
3427
program = "${drv}/bin/${drv.meta.mainProgram}";
3528
};
36-
in
37-
(flake-utils.lib.eachDefaultSystem (
38-
system:
29+
in (flake-utils.lib.eachDefaultSystem (system:
3930
let
4031
pkgs = import nixpkgs {
4132
inherit system;
4233
overlays = self.overlays.default;
4334
config = { };
4435
};
45-
in
46-
rec {
36+
in rec {
4737
packages = pkgs.cronos-matrix // {
4838
inherit (pkgs) rocksdb testground-image;
4939
};
@@ -59,41 +49,32 @@
5949
defaultApp = apps.cronosd;
6050
devShells = rec {
6151
default = pkgs.mkShell {
62-
buildInputs = [
63-
defaultPackage.go
64-
pkgs.gomod2nix
65-
];
52+
buildInputs = [ defaultPackage.go pkgs.gomod2nix ];
6653
};
6754
rocksdb = pkgs.mkShell {
68-
buildInputs = default.buildInputs ++ [
69-
pkgs.rocksdb
70-
pkgs.rocksdb.tools
71-
];
55+
buildInputs = default.buildInputs
56+
++ [ pkgs.rocksdb pkgs.rocksdb.tools ];
7257
};
7358
full = pkgs.mkShell {
74-
buildInputs = rocksdb.buildInputs ++ [
75-
pkgs.test-env
76-
];
59+
buildInputs = rocksdb.buildInputs ++ [ pkgs.test-env ];
7760
};
7861
};
7962
legacyPackages = pkgs;
80-
}
81-
))
82-
// {
83-
overlays.default = [
84-
(import ./nix/build_overlay.nix)
85-
poetry2nix.overlays.default
86-
gomod2nix.overlays.default
87-
(import ./testground/benchmark/overlay.nix)
88-
(final: super: {
89-
go = super.go_1_22;
90-
test-env = final.callPackage ./nix/testenv.nix { };
91-
cronos-matrix = final.callPackage ./nix/cronos-matrix.nix {
92-
inherit rev;
93-
bundle-exe = final.pkgsBuildBuild.callPackage nix-bundle-exe { };
94-
};
95-
testground-image = final.callPackage ./nix/testground-image.nix { };
96-
})
97-
];
98-
};
63+
})) // {
64+
overlays.default = [
65+
(import ./nix/build_overlay.nix)
66+
poetry2nix.overlays.default
67+
gomod2nix.overlays.default
68+
(import ./testground/benchmark/overlay.nix)
69+
(final: super: {
70+
go = super.go_1_22;
71+
test-env = final.callPackage ./nix/testenv.nix { };
72+
cronos-matrix = final.callPackage ./nix/cronos-matrix.nix {
73+
inherit rev;
74+
bundle-exe = final.pkgsBuildBuild.callPackage nix-bundle-exe { };
75+
};
76+
testground-image = final.callPackage ./nix/testground-image.nix { };
77+
})
78+
];
79+
};
9980
}
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
{
2-
pkgs ? import ../../nix { },
3-
}:
4-
let
5-
cronosd = (pkgs.callPackage ../../. { });
6-
in
7-
cronosd.overrideAttrs (oldAttrs: {
8-
patches = oldAttrs.patches or [ ] ++ [
9-
./broken-cronosd.patch
10-
];
11-
})
1+
{ pkgs ? import ../../nix { }, }:
2+
let cronosd = (pkgs.callPackage ../../. { });
3+
in cronosd.overrideAttrs
4+
(oldAttrs: { patches = oldAttrs.patches or [ ] ++ [ ./broken-cronosd.patch ]; })

integration_tests/configs/upgrade-test-package.nix

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
let
22
pkgs = import ../../nix { };
3-
fetchFlake =
4-
repo: rev:
3+
fetchFlake = repo: rev:
54
(pkgs.flake-compat {
65
src = {
7-
outPath = builtins.fetchTarball "https://github.com/${repo}/archive/${rev}.tar.gz";
6+
outPath = builtins.fetchTarball
7+
"https://github.com/${repo}/archive/${rev}.tar.gz";
88
inherit rev;
99
shortRev = builtins.substring 0 7 rev;
1010
};
1111
}).defaultNix;
1212
# v1.0.15
13-
releasedGenesis =
14-
(fetchFlake "crypto-org-chain/cronos" "1f5e2618362303d91f621b47cbc1115cf4fa0195").default;
13+
releasedGenesis = (fetchFlake "crypto-org-chain/cronos"
14+
"1f5e2618362303d91f621b47cbc1115cf4fa0195").default;
1515
# release/v1.1.x
16-
released1_1 =
17-
(fetchFlake "crypto-org-chain/cronos" "69a80154b6b24fca15f3562e2c4b312ee1092220").default;
16+
released1_1 = (fetchFlake "crypto-org-chain/cronos"
17+
"69a80154b6b24fca15f3562e2c4b312ee1092220").default;
1818
# release/v1.2.x
19-
released1_2 =
20-
(fetchFlake "crypto-org-chain/cronos" "1aea999eef67a0a01b22422bad94b36e45b9759a").default;
19+
released1_2 = (fetchFlake "crypto-org-chain/cronos"
20+
"1aea999eef67a0a01b22422bad94b36e45b9759a").default;
2121
# release/v1.3.x
22-
released1_3 =
23-
(fetchFlake "crypto-org-chain/cronos" "e1d819c862b30f0ce978baf2addb12516568639e").default;
22+
released1_3 = (fetchFlake "crypto-org-chain/cronos"
23+
"e1d819c862b30f0ce978baf2addb12516568639e").default;
2424
current = pkgs.callPackage ../../. { };
25-
in
26-
pkgs.linkFarm "upgrade-test-package" [
25+
in pkgs.linkFarm "upgrade-test-package" [
2726
{
2827
name = "genesis";
2928
path = releasedGenesis;

integration_tests/shell.nix

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
{
2-
system ? builtins.currentSystem,
3-
pkgs ? import ../nix { inherit system; },
4-
}:
5-
let
6-
renameExe = pkgs.callPackage ../nix/rename-exe.nix { };
7-
in
8-
pkgs.mkShell {
1+
{ system ? builtins.currentSystem, pkgs ? import ../nix { inherit system; }, }:
2+
let renameExe = pkgs.callPackage ../nix/rename-exe.nix { };
3+
in pkgs.mkShell {
94
buildInputs = [
105
pkgs.jq
116
pkgs.go
127
pkgs.gomod2nix
13-
(pkgs.callPackage ../. { coverage = true; }) # cronosd
8+
# (pkgs.callPackage ../. { coverage = true; }) # cronosd
149
pkgs.start-scripts
1510
pkgs.go-ethereum
1611
pkgs.cosmovisor
1712
pkgs.poetry
1813
pkgs.nodejs
1914
pkgs.git
20-
pkgs.dapp
21-
(renameExe pkgs.solc-static-versions.solc_0_6_8 "solc-0.6.8" "solc06")
22-
(renameExe pkgs.solc-static-versions.solc_0_8_21 "solc-0.8.21" "solc08")
15+
# pkgs.dapp
16+
# (renameExe pkgs.solc-static-versions.solc_0_6_8 "solc-0.6.8" "solc06")
17+
# (renameExe pkgs.solc-static-versions.solc_0_8_21 "solc-0.8.21" "solc08")
2318
pkgs.test-env
2419
pkgs.nixfmt
2520
pkgs.rocksdb

nix/bundle-win-exe.nix

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,25 @@
1-
{
2-
runCommand,
3-
windows,
4-
stdenv,
5-
rocksdb,
6-
bzip2,
7-
lz4,
8-
snappy,
9-
zstd,
10-
zlib,
11-
cronosd,
1+
{ runCommand, windows, stdenv, rocksdb, bzip2, lz4, snappy, zstd, zlib, cronosd,
122
}:
13-
runCommand "tarball-${cronosd.name}"
14-
{
15-
# manually enumerate the runtime dependencies of cronosd on mingwW64
16-
deps = [
17-
"${rocksdb}/bin/librocksdb-shared.dll"
18-
"${snappy}/bin/libsnappy.dll"
19-
"${lz4.out}/lib/liblz4.dll"
20-
"${bzip2.bin}/bin/libbz2-1.dll"
21-
"${zlib}/bin/zlib1.dll"
22-
"${zstd.bin}/bin/libzstd.dll"
23-
"${windows.mingw_w64_pthreads}/bin/libwinpthread-1.dll"
24-
"${windows.mcfgthreads}/bin/libmcfgthread-1.dll"
25-
"${stdenv.cc.cc.lib}/x86_64-w64-mingw32/lib/libgcc_s_seh-1.dll"
26-
"${stdenv.cc.cc.lib}/x86_64-w64-mingw32/lib/libstdc++-6.dll"
27-
];
28-
}
29-
''
30-
mkdir -p $out
31-
for so in $deps
32-
do
33-
cp $so $out/
34-
done
3+
runCommand "tarball-${cronosd.name}" {
4+
# manually enumerate the runtime dependencies of cronosd on mingwW64
5+
deps = [
6+
"${rocksdb}/bin/librocksdb-shared.dll"
7+
"${snappy}/bin/libsnappy.dll"
8+
"${lz4.out}/lib/liblz4.dll"
9+
"${bzip2.bin}/bin/libbz2-1.dll"
10+
"${zlib}/bin/zlib1.dll"
11+
"${zstd.bin}/bin/libzstd.dll"
12+
"${windows.mingw_w64_pthreads}/bin/libwinpthread-1.dll"
13+
"${windows.mcfgthreads}/bin/libmcfgthread-1.dll"
14+
"${stdenv.cc.cc.lib}/x86_64-w64-mingw32/lib/libgcc_s_seh-1.dll"
15+
"${stdenv.cc.cc.lib}/x86_64-w64-mingw32/lib/libstdc++-6.dll"
16+
];
17+
} ''
18+
mkdir -p $out
19+
for so in $deps
20+
do
21+
cp $so $out/
22+
done
3523
36-
cp ${cronosd}/bin/${cronosd.meta.mainProgram} $out/
37-
''
24+
cp ${cronosd}/bin/${cronosd.meta.mainProgram} $out/
25+
''

nix/cosmovisor.nix

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
{
2-
buildGoModule,
3-
fetchFromGitHub,
4-
}:
1+
{ buildGoModule, fetchFromGitHub, }:
52

63
let
74
version = "1.5.0";
@@ -11,8 +8,7 @@ let
118
rev = "tools/cosmovisor/v${version}";
129
hash = "sha256-Ov8FGpDOcsqmFLT2s/ubjmTXj17sQjBWRAdxlJ6DNEY=";
1310
};
14-
in
15-
buildGoModule rec {
11+
in buildGoModule rec {
1612
name = "cosmovisor";
1713
version = "1.5.0";
1814
src = cosmos-sdk + "/tools/cosmovisor";

0 commit comments

Comments
 (0)