@@ -30,6 +30,9 @@ pub struct Opts {
30
30
/// A list of flakes to deploy alternatively
31
31
#[ clap( long, group = "deploy" ) ]
32
32
targets : Option < Vec < String > > ,
33
+ /// Treat targets as files instead of flakes
34
+ #[ clap( short, long) ]
35
+ file : Option < String > ,
33
36
/// Check signatures when using `nix copy`
34
37
#[ clap( short, long) ]
35
38
checksigs : bool ,
@@ -672,15 +675,28 @@ pub async fn run(args: Option<&ArgMatches>) -> Result<(), RunError> {
672
675
error ! ( "Cannot use both --dry-activate & --boot!" ) ;
673
676
}
674
677
678
+ // if opts.file.is_some() && (opts.targets.is_some() || opts.target.is_some()) {
679
+ // error!("When using --file, only one target is supported!")
680
+ // }
681
+
675
682
let deploys = opts
676
683
. clone ( )
677
684
. targets
678
685
. unwrap_or_else ( || vec ! [ opts. clone( ) . target. unwrap_or_else( || "." . to_string( ) ) ] ) ;
679
686
680
- let deploy_flakes: Vec < DeployFlake > = deploys
687
+ let deploy_flakes: Vec < DeployFlake > =
688
+ if let Some ( file) = & opts. file {
689
+ deploys
690
+ . iter ( )
691
+ . map ( |f| deploy:: parse_file ( file. as_str ( ) , f. as_str ( ) ) )
692
+ . collect :: < Result < Vec < DeployFlake > , ParseFlakeError > > ( ) ?
693
+ }
694
+ else {
695
+ deploys
681
696
. iter ( )
682
697
. map ( |f| deploy:: parse_flake ( f. as_str ( ) ) )
683
- . collect :: < Result < Vec < DeployFlake > , ParseFlakeError > > ( ) ?;
698
+ . collect :: < Result < Vec < DeployFlake > , ParseFlakeError > > ( ) ?
699
+ } ;
684
700
685
701
let cmd_overrides = deploy:: CmdOverrides {
686
702
ssh_user : opts. ssh_user ,
@@ -700,22 +716,29 @@ pub async fn run(args: Option<&ArgMatches>) -> Result<(), RunError> {
700
716
} ;
701
717
702
718
let supports_flakes = test_flake_support ( ) . await . map_err ( RunError :: FlakeTest ) ?;
719
+ let do_not_want_flakes = opts. file . is_some ( ) ;
703
720
704
721
if !supports_flakes {
705
722
warn ! ( "A Nix version without flakes support was detected, support for this is work in progress" ) ;
706
723
}
707
724
725
+ if do_not_want_flakes {
726
+ warn ! ( "The --file option for deployments without flakes is experimental" ) ;
727
+ }
728
+
729
+ let using_flakes = supports_flakes && !do_not_want_flakes;
730
+
708
731
if !opts. skip_checks {
709
732
for deploy_flake in & deploy_flakes {
710
- check_deployment ( supports_flakes , deploy_flake. repo , & opts. extra_build_args ) . await ?;
733
+ check_deployment ( using_flakes , deploy_flake. repo , & opts. extra_build_args ) . await ?;
711
734
}
712
735
}
713
736
let result_path = opts. result_path . as_deref ( ) ;
714
- let data = get_deployment_data ( supports_flakes , & deploy_flakes, & opts. extra_build_args ) . await ?;
737
+ let data = get_deployment_data ( using_flakes , & deploy_flakes, & opts. extra_build_args ) . await ?;
715
738
run_deploy (
716
739
deploy_flakes,
717
740
data,
718
- supports_flakes ,
741
+ using_flakes ,
719
742
opts. checksigs ,
720
743
opts. interactive ,
721
744
& cmd_overrides,
0 commit comments