@@ -40,6 +40,10 @@ struct Opts {
40
40
#[ clap( short, long) ]
41
41
result_path : Option < String > ,
42
42
43
+ /// Skip the automatic pre-build checks
44
+ #[ clap( short, long) ]
45
+ skip_checks : bool ,
46
+
43
47
/// Override the SSH user with the given value
44
48
#[ clap( long) ]
45
49
ssh_user : Option < String > ,
@@ -197,8 +201,42 @@ async fn test_flake_support() -> Result<bool, Box<dyn std::error::Error>> {
197
201
. success ( ) )
198
202
}
199
203
204
+ async fn check_deployment ( supports_flakes : bool , repo : & str , extra_build_args : & [ String ] ) -> ( ) {
205
+ let mut c = match supports_flakes {
206
+ true => Command :: new ( "nix" ) ,
207
+ false => Command :: new ( "nix-build" ) ,
208
+ } ;
209
+
210
+ let mut check_command = match supports_flakes {
211
+ true => {
212
+ c. arg ( "flake" )
213
+ . arg ( "check" )
214
+ . arg ( repo)
215
+ }
216
+ false => {
217
+ c. arg ( "-E" )
218
+ . arg ( "--no-out-link" )
219
+ . arg ( format ! ( "let r = import {}/.; in (if builtins.isFunction r then (r {{}}) else r).checks.${{builtins.currentSystem}}" , repo) )
220
+ }
221
+ } ;
222
+
223
+ for extra_arg in extra_build_args {
224
+ check_command = check_command. arg ( extra_arg) ;
225
+ }
226
+
227
+ let check_status = match check_command. status ( ) . await {
228
+ Ok ( x) => x,
229
+ Err ( err) => good_panic ! ( "Error running checks for the given flake repo: {:?}" , err) ,
230
+ } ;
231
+
232
+ if !check_status. success ( ) {
233
+ good_panic ! ( "Checks failed for the given flake repo" ) ;
234
+ }
235
+
236
+ ( )
237
+ }
238
+
200
239
/// Evaluates the Nix in the given `repo` and return the processed Data from it
201
- #[ inline]
202
240
async fn get_deployment_data (
203
241
supports_flakes : bool ,
204
242
repo : & str ,
@@ -374,6 +412,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
374
412
warn ! ( "A Nix version without flakes support was detected, support for this is work in progress" ) ;
375
413
}
376
414
415
+ if !opts. skip_checks {
416
+ check_deployment ( supports_flakes, deploy_flake. repo , & opts. extra_build_args ) . await ;
417
+ }
418
+
377
419
let data =
378
420
get_deployment_data ( supports_flakes, deploy_flake. repo , & opts. extra_build_args ) . await ?;
379
421
0 commit comments