@@ -23,13 +23,9 @@ use tokio::process::Command;
23
23
#[ derive( Parser , Debug , Clone ) ]
24
24
#[ command( version = "1.0" , author = "Serokell <https://serokell.io/>" ) ]
25
25
pub struct Opts {
26
- /// The flake to deploy
27
- #[ arg( group = "deploy" ) ]
28
- target : Option < String > ,
29
-
30
- /// A list of flakes to deploy alternatively
31
- #[ arg( long, group = "deploy" ) ]
32
- targets : Option < Vec < String > > ,
26
+ /// A flake to deploy, can be repeated
27
+ #[ arg( long, action = clap:: ArgAction :: Append ) ]
28
+ target : Option < Vec < String > > ,
33
29
/// Treat targets as files instead of flakes
34
30
#[ clap( short, long) ]
35
31
file : Option < String > ,
@@ -39,9 +35,6 @@ pub struct Opts {
39
35
/// Use the interactive prompt before deployment
40
36
#[ arg( short, long) ]
41
37
interactive : bool ,
42
- /// Extra arguments to be passed to nix build
43
- extra_build_args : Vec < String > ,
44
-
45
38
/// Print debug logs to output
46
39
#[ arg( short, long) ]
47
40
debug_logs : bool ,
@@ -109,6 +102,15 @@ pub struct Opts {
109
102
/// Prompt for sudo password during activation.
110
103
#[ arg( long) ]
111
104
interactive_sudo : Option < bool > ,
105
+
106
+ #[ command( subcommand) ]
107
+ command : Option < Passthrough > ,
108
+ }
109
+
110
+ #[ derive( Parser , Debug , Clone ) ]
111
+ enum Passthrough {
112
+ #[ clap( external_subcommand) ]
113
+ Args ( Vec < String > ) ,
112
114
}
113
115
114
116
/// Returns if the available Nix installation supports flakes
@@ -607,8 +609,8 @@ async fn run_deploy(
607
609
let mut succeeded: Vec < ( & deploy:: DeployData , & deploy:: DeployDefs ) > = vec ! [ ] ;
608
610
609
611
// Run all deployments
610
- // In case of an error rollback any previoulsy made deployment.
611
- // Rollbacks adhere to the global seeting to auto_rollback and secondary
612
+ // In case of an error rollback any previously made deployment.
613
+ // Rollbacks adhere to the global setting to auto_rollback and secondary
612
614
// the profile's configuration
613
615
for ( _, deploy_data, deploy_defs) in & parts {
614
616
if let Err ( e) = deploy:: deploy:: deploy_profile ( deploy_data, deploy_defs, dry_activate, boot) . await
@@ -620,7 +622,7 @@ async fn run_deploy(
620
622
if rollback_succeeded && cmd_overrides. auto_rollback . unwrap_or ( true ) {
621
623
info ! ( "Revoking previous deploys" ) ;
622
624
// revoking all previous deploys
623
- // (adheres to profile configuration if not set explicitely by
625
+ // (adheres to profile configuration if not set explicitly by
624
626
// the command line)
625
627
for ( deploy_data, deploy_defs) in & succeeded {
626
628
if deploy_data. merged_settings . auto_rollback . unwrap_or ( true ) {
@@ -678,9 +680,14 @@ pub async fn run(args: Option<&ArgMatches>) -> Result<(), RunError> {
678
680
}
679
681
680
682
let deploys = opts
681
- . clone ( )
682
- . targets
683
- . unwrap_or_else ( || vec ! [ opts. clone( ) . target. unwrap_or_else( || "." . to_string( ) ) ] ) ;
683
+ . target
684
+ . unwrap_or_else ( || vec ! [ "." . to_string( ) ] ) ;
685
+
686
+ let extra_build_args = if let Some ( Passthrough :: Args ( args) ) = opts. command {
687
+ args
688
+ } else {
689
+ Vec :: new ( )
690
+ } ;
684
691
685
692
let deploy_flakes: Vec < DeployFlake > =
686
693
if let Some ( file) = & opts. file {
@@ -728,11 +735,11 @@ pub async fn run(args: Option<&ArgMatches>) -> Result<(), RunError> {
728
735
729
736
if !opts. skip_checks {
730
737
for deploy_flake in & deploy_flakes {
731
- check_deployment ( using_flakes, deploy_flake. repo , & opts . extra_build_args ) . await ?;
738
+ check_deployment ( using_flakes, deploy_flake. repo , & extra_build_args) . await ?;
732
739
}
733
740
}
734
741
let result_path = opts. result_path . as_deref ( ) ;
735
- let data = get_deployment_data ( using_flakes, & deploy_flakes, & opts . extra_build_args ) . await ?;
742
+ let data = get_deployment_data ( using_flakes, & deploy_flakes, & extra_build_args) . await ?;
736
743
run_deploy (
737
744
deploy_flakes,
738
745
data,
@@ -742,7 +749,7 @@ pub async fn run(args: Option<&ArgMatches>) -> Result<(), RunError> {
742
749
& cmd_overrides,
743
750
opts. keep_result ,
744
751
result_path,
745
- & opts . extra_build_args ,
752
+ & extra_build_args,
746
753
opts. debug_logs ,
747
754
opts. dry_activate ,
748
755
opts. boot ,
0 commit comments