forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
197 lines (181 loc) · 6.2 KB
/
flake.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
{
description = "A Framework for Building High Value Public Blockchains";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
swagger-combine-src = {
flake = false;
url = "github:maxdome/swagger-combine";
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
protoc-gen-go-cosmos-orm = {
url = "github:cosmos/cosmos-sdk?rev=cd45ab2abdd9817a0ebb583f5334514e3f900cfb";
flake = false;
};
cosmosproto = {
url = "github:cosmos/cosmos-proto?rev=0748a2ad4a5c78b1db6c8090db01e255bcc91365";
flake = false;
};
gogoproto = {
url = "github:cosmos/gogoproto?rev=b12c8cae0624d2518ab995c775410694dfa5d50e";
flake = false;
};
googleapis = {
url = "github:googleapis/googleapis?rev=8984ddb508dea0e673b724c58338e810b1d8aee3";
flake = false;
};
cometbft = {
url = "github:unionlabs/cometbft?rev=8e5f9640051521f4adc92137d40568f9e7f0d3e4";
flake = false;
};
};
outputs = inputs@{ nixpkgs, flake-parts, treefmt-nix, protoc-gen-go-cosmos-orm, cosmosproto, gogoproto, googleapis, cometbft, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems =
[ "x86_64-linux" "aarch64-linux" ];
imports = [
./client/v2/clientv2.nix
./proto/proto.nix
./simapp/simapp.nix
./tests/tests.nix
treefmt-nix.flakeModule
];
perSystem = { config, self', inputs', pkgs, system, lib, ... }:
let
mkUnpack = import ./tools/mkUnpack.nix { inherit pkgs; };
in
{
_module = {
args = {
inherit nixpkgs;
pkgs = import nixpkgs {
inherit system;
};
rev =
if (builtins.hasAttr "rev" self') then self'.rev else "dev";
proto = {
protoc-gen-go-cosmos-orm = mkUnpack {
name = "protoc-gen-go-cosmos-orm";
package = protoc-gen-go-cosmos-orm;
};
cosmossdk = builtins.path {
name = "cosmos-sdk";
path = ./.;
};
cosmosproto = mkUnpack {
name = "cosmos-proto";
package = cosmosproto;
};
gogoproto = mkUnpack {
name = "gogoproto";
package = gogoproto;
};
googleapis = mkUnpack {
name = "googleapis";
package = googleapis;
};
cometbft = mkUnpack {
name = "cometbft";
package = cometbft;
};
};
};
};
packages = {
go-mod-vendor = pkgs.writeShellApplication {
name = "go-mod-vendor";
runtimeInputs = with pkgs; [ go_1_23 ];
text = ''
# If the current directory contains flake.nix, then we are at the repository root
if [[ -f flake.nix ]]
then
echo "We are at the repository root. Running script..."
else
echo "We are NOT at the repository root. Please cd to the repository root and try again."
exit 1
fi
for project in \
./. \
./client/v2/ \
./simapp/ \
./tests/
do
echo "Vendoring '$project'..."
(
cd $project;
rm -rf vendor/*;
go mod tidy;
go mod vendor;
)
done
echo "Done vendoring!"
'';
};
swagger-combine = pkgs.buildNpmPackage {
pname = "swagger-combine";
version = "10.0.9";
src = inputs.swagger-combine-src;
dontNpmBuild = true;
npmDepsHash = "sha256-FZR8hefkqTwSZJMX4lzS4zk7iGXi0+zi0ol1ia3iLYs=";
};
};
packages = {
default = self'.packages.simapp;
};
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
buf
go_1_23
gopls
gotestsum
go-tools
gotools
jq
marksman
nil
openssl
protobuf
rocksdb_8_11
];
nativeBuildInputs = [ config.treefmt.build.wrapper ];
PROTOC = "${pkgs.protobuf}/bin/protoc";
SWAGGER_BIN = "${self'.packages.swagger-combine}/bin/swagger-combine";
GOPRIVATE = "github.com/unionlabs/*";
};
treefmt = {
projectRootFile = "flake.nix";
programs.nixpkgs-fmt.enable = true;
settings.global.excludes = [ "./vendor*" "*.git*" "./client/docs/statik/statik.go" "./test/mocks/*" "*.pb.go" "*.pb.gw.go" "*.pulsar.go" "./crypto/keys/secp256k1/*" ];
};
checks = {
go-test = pkgs.go.stdenv.mkDerivation {
name = "go-test";
buildInputs = [ pkgs.go_1_23 pkgs.gotestsum pkgs.git pkgs.which ];
src = ./.;
doCheck = true;
dontInstall = true;
dontBuild = true;
checkPhase = ''
# Go will try to create a .cache/ dir in $HOME.
# We avoid this by setting $HOME to the builder directory
export HOME=$(pwd)
export GOFLAGS="-tags=\"cgo,ledger,test_ledger_mock,norace\""
export GOPRIVATE="github.com/unionlabs/*";
export GOWORK="off"
go version
echo "Starting tests for github.com/cosmos/cosmos-sdk"
gotestsum ./...
echo "Finished running sub module tests."
touch $out
'';
};
};
};
};
}