4
4
inputs = {
5
5
nixpkgs . url = "github:NixOS/nixpkgs/nixos-unstable" ;
6
6
7
- crane = {
8
- url = "github:ipetkov/crane" ;
9
- inputs . nixpkgs . follows = "nixpkgs" ;
10
- } ;
7
+ crane . url = "github:ipetkov/crane" ;
11
8
12
9
fenix = {
13
10
url = "github:nix-community/fenix" ;
42
39
43
40
craneLib = ( crane . mkLib pkgs ) . overrideToolchain rustToolchain ;
44
41
45
- # Common build inputs for all targets
46
- commonArgs = {
47
- src = pkgs . lib . cleanSourceWith {
48
- src = self ;
49
- filter = path : type :
50
- # Include all files that crane normally includes
51
- ( craneLib . filterCargoSources path type ) ||
52
- # Also include examples directories and JSON files
53
- ( pkgs . lib . hasSuffix "examples" path ) ||
54
- ( pkgs . lib . hasSuffix ".json" path ) ;
55
- } ;
56
-
57
- buildInputs = with pkgs ; [
58
- openssl
59
- libclang . lib
60
- ] ++ pkgs . lib . optionals pkgs . stdenv . hostPlatform . isLinux [
61
- pkgs . rust-jemalloc-sys-unprefixed
62
- ] ++ pkgs . lib . optionals pkgs . stdenv . hostPlatform . isDarwin [
63
- pkgs . darwin . apple_sdk . frameworks . SystemConfiguration
64
- pkgs . darwin . apple_sdk . frameworks . Security
65
- ] ;
66
-
67
- nativeBuildInputs = with pkgs ; [
68
- pkg-config
69
- protobuf
70
- llvmPackages . lld
71
- ] ;
72
-
73
- # Environment variables
42
+ shellEnv = {
74
43
CC_ENABLE_DEBUG_OUTPUT = "1" ;
75
44
CRATE_CC_NO_DEFAULTS = 1 ;
76
45
LD_LIBRARY_PATH = pkgs . lib . makeLibraryPath [
83
52
BINDGEN_EXTRA_CLANG_ARGS = if pkgs . lib . hasSuffix "linux" system then "-I${ pkgs . glibc . dev } /include -I${ pkgs . clang . cc . lib } /lib/clang/19/include" else "" ;
84
53
LIBCLANG_PATH = "${ pkgs . clang . cc . lib } /lib" ;
85
54
86
- # Platform-specific flags
87
55
CFLAGS = if pkgs . lib . hasSuffix "linux" system then
88
56
"-DJEMALLOC_STRERROR_R_RETURNS_CHAR_WITH_GNU_SOURCE"
89
57
else
90
58
"" ;
91
59
92
60
PROTOC = "${ pkgs . protobuf } /bin/protoc" ;
93
- doCheck = false ;
94
61
#C_INCLUDE_PATH = "${pkgs.clang.cc.lib}/lib/clang/19/include";
95
62
96
63
# RocksDB configuration - use system library
102
69
103
70
RUSTFLAGS = pkgs . lib . optionalString pkgs . stdenv . hostPlatform . isDarwin
104
71
"--cfg unwinding_backport --cfg unwinding_apple" ;
105
-
106
72
} ;
107
73
108
- # Build the workspace dependencies
74
+ # Common build inputs for all targets
75
+ commonArgs = {
76
+ pname = "partner-chains-demo-node" ;
77
+ src = pkgs . lib . cleanSourceWith {
78
+ src = self ;
79
+ filter = path : type :
80
+ ( craneLib . filterCargoSources path type ) ||
81
+ ( pkgs . lib . hasSuffix "examples" path ) ||
82
+ ( pkgs . lib . hasSuffix ".json" path ) ;
83
+ } ;
84
+
85
+ buildInputs = with pkgs ; [
86
+ openssl
87
+ libclang . lib
88
+ ] ++ pkgs . lib . optionals pkgs . stdenv . hostPlatform . isLinux [
89
+ pkgs . rust-jemalloc-sys-unprefixed
90
+ ] ++ pkgs . lib . optionals pkgs . stdenv . hostPlatform . isDarwin [
91
+ pkgs . darwin . apple_sdk . frameworks . SystemConfiguration
92
+ pkgs . darwin . apple_sdk . frameworks . Security
93
+ ] ;
94
+
95
+ nativeBuildInputs = with pkgs ; [
96
+ pkg-config
97
+ protobuf
98
+ llvmPackages . lld
99
+ ] ;
100
+
101
+ doCheck = false ;
102
+ } // shellEnv ;
103
+
104
+ # Build the workspace dependencies separately
109
105
cargoArtifacts = craneLib . buildDepsOnly ( commonArgs // {
110
- pname = "partner-chains-deps" ;
106
+ pname = "partner-chains-demo-node- deps" ;
111
107
} ) ;
112
108
113
- # Build the main binary
114
- partner-chains = craneLib . buildPackage ( commonArgs // {
115
- pname = "partner-chains" ;
109
+ partner-chains-demo-node = craneLib . buildPackage ( commonArgs // {
110
+ pname = "partner-chains-demo-node" ;
116
111
version = ( builtins . fromTOML ( builtins . readFile ./Cargo.toml ) ) . workspace . package . version ;
117
112
118
113
inherit cargoArtifacts ;
119
114
120
- # Git commit hash for Substrate CLI
115
+ # Git commit hash for partner-chains CLI --version flag
121
116
SUBSTRATE_CLI_GIT_COMMIT_HASH = self . dirtyShortRev or self . shortRev ;
122
117
123
118
postFixup = pkgs . lib . optionalString pkgs . stdenv . hostPlatform . isLinux ''
124
119
patchelf --set-rpath "${ pkgs . rocksdb } /lib:${ pkgs . stdenv . cc . cc . lib } /lib" $out/bin/partner-chains-demo-node
125
120
'' ;
126
121
} ) ;
127
122
128
- # Run tests
129
123
cargoTest = craneLib . cargoTest ( commonArgs // {
130
124
inherit cargoArtifacts ;
131
125
} ) ;
132
126
133
- # Run clippy
134
127
cargoClippy = craneLib . cargoClippy ( commonArgs // {
135
128
inherit cargoArtifacts ;
136
129
cargoClippyExtraArgs = "--all-targets -- --deny warnings" ;
137
130
} ) ;
138
131
139
- # Run fmt check
140
132
cargoFmt = craneLib . cargoFmt {
141
- inherit ( commonArgs ) src ;
133
+ inherit ( commonArgs ) pname src ;
142
134
} ;
143
135
144
136
in
145
137
{
146
- checks = {
138
+ checks = {
147
139
# Build the crate as part of `nix flake check`
148
- inherit partner-chains cargoTest cargoClippy cargoFmt ;
140
+ inherit partner-chains-demo-node cargoTest cargoClippy cargoFmt ;
149
141
} ;
150
142
151
143
packages = {
152
- default = partner-chains ;
153
- inherit partner-chains ;
144
+ default = partner-chains-demo-node ;
145
+ inherit partner-chains-demo-node ;
154
146
} ;
147
+ devShells . default = craneLib . devShell ( {
148
+ name = "partner-chains-demo-node-shell" ;
149
+ # Inherit inputs from checks, which pulls in the build environment from packages.default (and others)
150
+ checks = self . checks . ${ system } ;
155
151
156
- devShells . default = pkgs . mkShell {
152
+ # Extra packages for the dev shell
157
153
packages = with pkgs ; [
158
154
awscli2
159
155
bashInteractive
160
156
cargo-edit
161
157
cargo-license
162
158
coreutils
163
159
docker-compose
164
- earthly
165
160
gawk
166
161
gnumake
167
162
kubectl
177
172
rustToolchain
178
173
sops
179
174
xxd
180
- ] ++ ( if pkgs . stdenv . hostPlatform . isDarwin then
181
- [ pkgs . darwin . apple_sdk . frameworks . SystemConfiguration ]
182
- else
183
- [ pkgs . clang ] ) ;
184
-
185
- shellHook = ''
186
- export RUST_SRC_PATH="${ rustToolchain } /lib/rustlib/src/rust/library"
187
- export LIBCLANG_PATH="${ pkgs . libclang . lib } /lib"
188
- export LD_LIBRARY_PATH="${
189
- pkgs . lib . makeLibraryPath [
190
- rustToolchain
191
- pkgs . libz
192
- pkgs . stdenv . cc . cc
193
- ]
194
- } "
195
-
196
- export OPENSSL_NO_VENDOR=1
197
- export OPENSSL_DIR="${ pkgs . openssl . dev } "
198
- export OPENSSL_INCLUDE_DIR="${ pkgs . openssl . dev } /include"
199
- export OPENSSL_LIB_DIR="${ pkgs . openssl . out } /lib"
200
-
201
- export PYTHONNOUSERSITE=1
202
- export CRATE_CC_NO_DEFAULTS=1
203
- ${ if pkgs . stdenv . hostPlatform . isLinux then "export CFLAGS=-DJEMALLOC_STRERROR_R_RETURNS_CHAR_WITH_GNU_SOURCE" else "" }
204
- '' ;
205
- } ;
175
+ ] ++ ( if pkgs . stdenv . hostPlatform . isDarwin then
176
+ [ pkgs . darwin . apple_sdk . frameworks . SystemConfiguration ]
177
+ else
178
+ [ pkgs . clang ] ) ;
179
+ } // shellEnv ) ;
206
180
207
181
formatter = pkgs . nixfmt-rfc-style ;
208
182
} ) ;
221
195
"cache.sc.iog.io:b4YIcBabCEVKrLQgGW8Fylz4W8IvvfzRc+hy0idqrWU="
222
196
] ;
223
197
} ;
224
- }
198
+ }
0 commit comments