Skip to content

Commit 914b7cc

Browse files
author
HuangYi
committed
Problem: nixpkgs-fmt is deprecated
Solution: - switch to nixfmt
1 parent 45c9292 commit 914b7cc

22 files changed

+657
-406
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ lint-py:
131131
--format="::error file=%(path)s,line=%(row)d,col=%(col)d::%(path)s:%(row)d:%(col)d: %(code)s %(text)s" \
132132

133133
lint-nix:
134-
find . -name "*.nix" ! -path './integration_tests/contracts/*' ! -path "./contracts/*" | xargs nixpkgs-fmt --check
134+
find . -name "*.nix" ! -path './integration_tests/contracts/*' ! -path "./contracts/*" | xargs nixfmt -c
135135

136136
.PHONY: lint lint-fix lint-py
137137

default.nix

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
1-
{ lib
2-
, stdenv
3-
, buildGoApplication
4-
, nix-gitignore
5-
, buildPackages
6-
, coverage ? false # https://tip.golang.org/doc/go1.20#cover
7-
, rocksdb
8-
, network ? "mainnet" # mainnet|testnet
9-
, rev ? "dirty"
10-
, static ? stdenv.hostPlatform.isStatic
11-
, nativeByteOrder ? true # nativeByteOrder mode will panic on big endian machines
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
1213
}:
1314
let
1415
version = "v1.4.0";
1516
pname = "cronosd";
16-
tags = [ "ledger" "netgo" network "rocksdb" "grocksdb_no_link" "pebbledb" "objstore" ] ++ lib.optionals nativeByteOrder [ "nativebyteorder" ];
17+
tags = [
18+
"ledger"
19+
"netgo"
20+
network
21+
"rocksdb"
22+
"grocksdb_no_link"
23+
"pebbledb"
24+
"objstore"
25+
] ++ lib.optionals nativeByteOrder [ "nativebyteorder" ];
1726
ldflags = lib.concatStringsSep "\n" ([
1827
"-X github.com/cosmos/cosmos-sdk/version.Name=cronos"
1928
"-X github.com/cosmos/cosmos-sdk/version.AppName=${pname}"
@@ -24,29 +33,40 @@ let
2433
buildInputs = [ rocksdb ];
2534
in
2635
buildGoApplication rec {
27-
inherit pname version buildInputs tags ldflags;
28-
src = (nix-gitignore.gitignoreSourcePure [
29-
"/*" # ignore all, then add whitelists
30-
"!/x/"
31-
"!/app/"
32-
"!/cmd/"
33-
"!/client/"
34-
"!/versiondb/"
35-
"!/memiavl/"
36-
"!/store/"
37-
"!go.mod"
38-
"!go.sum"
39-
"!gomod2nix.toml"
40-
] ./.);
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+
);
4158
modules = ./gomod2nix.toml;
4259
pwd = src; # needed to support replace
4360
subPackages = [ "cmd/cronosd" ];
4461
buildFlags = lib.optionalString coverage "-cover";
4562
CGO_ENABLED = "1";
4663
CGO_LDFLAGS = lib.optionalString (rocksdb != null) (
47-
if static then "-lrocksdb -pthread -lstdc++ -ldl -lzstd -lsnappy -llz4 -lbz2 -lz"
48-
else if stdenv.hostPlatform.isWindows then "-lrocksdb-shared"
49-
else "-lrocksdb -pthread -lstdc++ -ldl"
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"
5070
);
5171

5272
postFixup = lib.optionalString (stdenv.isDarwin && rocksdb != null) ''

flake.nix

Lines changed: 51 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -18,60 +18,68 @@
1818
};
1919
};
2020

21-
outputs = { self, nixpkgs, nix-bundle-exe, gomod2nix, flake-utils, poetry2nix }:
21+
outputs =
22+
{
23+
self,
24+
nixpkgs,
25+
nix-bundle-exe,
26+
gomod2nix,
27+
flake-utils,
28+
poetry2nix,
29+
}:
2230
let
2331
rev = self.shortRev or "dirty";
2432
mkApp = drv: {
2533
type = "app";
2634
program = "${drv}/bin/${drv.meta.mainProgram}";
2735
};
2836
in
29-
(flake-utils.lib.eachDefaultSystem
30-
(system:
31-
let
32-
pkgs = import nixpkgs {
33-
inherit system;
34-
overlays = self.overlays.default;
35-
config = { };
37+
(flake-utils.lib.eachDefaultSystem (
38+
system:
39+
let
40+
pkgs = import nixpkgs {
41+
inherit system;
42+
overlays = self.overlays.default;
43+
config = { };
44+
};
45+
in
46+
rec {
47+
packages = pkgs.cronos-matrix // {
48+
inherit (pkgs) rocksdb testground-image;
49+
};
50+
apps = {
51+
cronosd = mkApp packages.cronosd;
52+
cronosd-testnet = mkApp packages.cronosd-testnet;
53+
stateless-testcase = {
54+
type = "app";
55+
program = "${pkgs.benchmark-testcase}/bin/stateless-testcase";
3656
};
37-
in
38-
rec {
39-
packages = pkgs.cronos-matrix // {
40-
inherit (pkgs) rocksdb testground-image;
57+
};
58+
defaultPackage = packages.cronosd;
59+
defaultApp = apps.cronosd;
60+
devShells = rec {
61+
default = pkgs.mkShell {
62+
buildInputs = [
63+
defaultPackage.go
64+
pkgs.gomod2nix
65+
];
4166
};
42-
apps = {
43-
cronosd = mkApp packages.cronosd;
44-
cronosd-testnet = mkApp packages.cronosd-testnet;
45-
stateless-testcase = {
46-
type = "app";
47-
program = "${pkgs.benchmark-testcase}/bin/stateless-testcase";
48-
};
67+
rocksdb = pkgs.mkShell {
68+
buildInputs = default.buildInputs ++ [
69+
pkgs.rocksdb
70+
pkgs.rocksdb.tools
71+
];
4972
};
50-
defaultPackage = packages.cronosd;
51-
defaultApp = apps.cronosd;
52-
devShells = rec {
53-
default = pkgs.mkShell {
54-
buildInputs = [
55-
defaultPackage.go
56-
pkgs.gomod2nix
57-
];
58-
};
59-
rocksdb = pkgs.mkShell {
60-
buildInputs = default.buildInputs ++ [
61-
pkgs.rocksdb
62-
pkgs.rocksdb.tools
63-
];
64-
};
65-
full = pkgs.mkShell {
66-
buildInputs = rocksdb.buildInputs ++ [
67-
pkgs.test-env
68-
];
69-
};
73+
full = pkgs.mkShell {
74+
buildInputs = rocksdb.buildInputs ++ [
75+
pkgs.test-env
76+
];
7077
};
71-
legacyPackages = pkgs;
72-
}
73-
)
74-
) // {
78+
};
79+
legacyPackages = pkgs;
80+
}
81+
))
82+
// {
7583
overlays.default = [
7684
(import ./nix/build_overlay.nix)
7785
poetry2nix.overlays.default

integration_tests/configs/broken-cronosd.nix

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
{ pkgs ? import ../../nix { } }:
2-
let cronosd = (pkgs.callPackage ../../. { });
1+
{
2+
pkgs ? import ../../nix { },
3+
}:
4+
let
5+
cronosd = (pkgs.callPackage ../../. { });
36
in
47
cronosd.overrideAttrs (oldAttrs: {
58
patches = oldAttrs.patches or [ ] ++ [
Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,47 @@
11
let
22
pkgs = import ../../nix { };
3-
fetchFlake = repo: rev: (pkgs.flake-compat {
4-
src = {
5-
outPath = builtins.fetchTarball "https://github.com/${repo}/archive/${rev}.tar.gz";
6-
inherit rev;
7-
shortRev = builtins.substring 0 7 rev;
8-
};
9-
}).defaultNix;
3+
fetchFlake =
4+
repo: rev:
5+
(pkgs.flake-compat {
6+
src = {
7+
outPath = builtins.fetchTarball "https://github.com/${repo}/archive/${rev}.tar.gz";
8+
inherit rev;
9+
shortRev = builtins.substring 0 7 rev;
10+
};
11+
}).defaultNix;
1012
# v1.0.15
11-
releasedGenesis = (fetchFlake "crypto-org-chain/cronos" "1f5e2618362303d91f621b47cbc1115cf4fa0195").default;
13+
releasedGenesis =
14+
(fetchFlake "crypto-org-chain/cronos" "1f5e2618362303d91f621b47cbc1115cf4fa0195").default;
1215
# release/v1.1.x
13-
released1_1 = (fetchFlake "crypto-org-chain/cronos" "69a80154b6b24fca15f3562e2c4b312ee1092220").default;
16+
released1_1 =
17+
(fetchFlake "crypto-org-chain/cronos" "69a80154b6b24fca15f3562e2c4b312ee1092220").default;
1418
# release/v1.2.x
15-
released1_2 = (fetchFlake "crypto-org-chain/cronos" "1aea999eef67a0a01b22422bad94b36e45b9759a").default;
19+
released1_2 =
20+
(fetchFlake "crypto-org-chain/cronos" "1aea999eef67a0a01b22422bad94b36e45b9759a").default;
1621
# release/v1.3.x
17-
released1_3 = (fetchFlake "crypto-org-chain/cronos" "e1d819c862b30f0ce978baf2addb12516568639e").default;
22+
released1_3 =
23+
(fetchFlake "crypto-org-chain/cronos" "e1d819c862b30f0ce978baf2addb12516568639e").default;
1824
current = pkgs.callPackage ../../. { };
1925
in
2026
pkgs.linkFarm "upgrade-test-package" [
21-
{ name = "genesis"; path = releasedGenesis; }
22-
{ name = "v1.1.0"; path = released1_1; }
23-
{ name = "v1.2"; path = released1_2; }
24-
{ name = "v1.3"; path = released1_3; }
25-
{ name = "v1.4"; path = current; }
27+
{
28+
name = "genesis";
29+
path = releasedGenesis;
30+
}
31+
{
32+
name = "v1.1.0";
33+
path = released1_1;
34+
}
35+
{
36+
name = "v1.2";
37+
path = released1_2;
38+
}
39+
{
40+
name = "v1.3";
41+
path = released1_3;
42+
}
43+
{
44+
name = "v1.4";
45+
path = current;
46+
}
2647
]

integration_tests/shell.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
{ system ? builtins.currentSystem, pkgs ? import ../nix { inherit system; } }:
1+
{
2+
system ? builtins.currentSystem,
3+
pkgs ? import ../nix { inherit system; },
4+
}:
25
let
36
renameExe = pkgs.callPackage ../nix/rename-exe.nix { };
47
in

nix/bundle-win-exe.nix

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

nix/cosmovisor.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
{ buildGoModule
2-
, fetchFromGitHub
1+
{
2+
buildGoModule,
3+
fetchFromGitHub,
34
}:
45

56
let

0 commit comments

Comments
 (0)