@@ -14,6 +14,7 @@ use crate::{
1414 interface:: {
1515 self ,
1616 DiffType ,
17+ NotifyAskMode ,
1718 OsBuildVmArgs ,
1819 OsGenerationsArgs ,
1920 OsRebuildArgs ,
@@ -22,6 +23,7 @@ use crate::{
2223 OsSubcommand :: { self } ,
2324 } ,
2425 nh_info,
26+ notify:: NotificationSender ,
2527 update:: update,
2628 util:: { ensure_ssh_key_login, get_hostname, print_dix_diff} ,
2729} ;
@@ -39,7 +41,7 @@ impl interface::OsArgs {
3941 OsSubcommand :: Test ( args) => args. rebuild ( & Test , None , elevation) ,
4042 OsSubcommand :: Switch ( args) => args. rebuild ( & Switch , None , elevation) ,
4143 OsSubcommand :: Build ( args) => {
42- if args. common . ask || args. common . dry {
44+ if args. common . ask . is_some ( ) || args. common . dry {
4345 warn ! ( "`--ask` and `--dry` have no effect for `nh os build`" ) ;
4446 }
4547 args. rebuild ( & Build , None , elevation)
@@ -132,7 +134,7 @@ impl OsRebuildArgs {
132134 self . handle_dix_diff ( & target_profile) ;
133135
134136 if self . common . dry || matches ! ( variant, Build | BuildVm ) {
135- if self . common . ask {
137+ if self . common . ask . is_some ( ) {
136138 warn ! ( "--ask has no effect as dry run was requested" ) ;
137139 }
138140
@@ -317,10 +319,22 @@ impl OsRebuildArgs {
317319 ) -> Result < ( ) > {
318320 use OsRebuildVariant :: { Boot , Switch , Test } ;
319321
320- if self . common . ask {
321- let confirmation = inquire:: Confirm :: new ( "Apply the config?" )
322- . with_default ( false )
323- . prompt ( ) ?;
322+ if let Some ( ask) = & self . common . ask {
323+ let confirmation = match ask {
324+ NotifyAskMode :: Prompt => {
325+ inquire:: Confirm :: new ( "Apply the config?" )
326+ . with_default ( false )
327+ . prompt ( ) ?
328+ } ,
329+ #[ cfg( all( unix, not( target_os = "macos" ) ) ) ]
330+ NotifyAskMode :: Notify => {
331+ NotificationSender :: new (
332+ "nh os switch" ,
333+ "Do you want to apply the NixOS configuration?" ,
334+ )
335+ . ask ( )
336+ } ,
337+ } ;
324338
325339 if !confirmation {
326340 bail ! ( "User rejected the new config" ) ;
@@ -465,13 +479,25 @@ impl OsRollbackArgs {
465479 return Ok ( ( ) ) ;
466480 }
467481
468- if self . ask {
469- let confirmation = inquire:: Confirm :: new ( & format ! (
470- "Roll back to generation {}?" ,
471- target_generation. number
472- ) )
473- . with_default ( false )
474- . prompt ( ) ?;
482+ if let Some ( ask) = & self . ask {
483+ let confirmation = match ask {
484+ NotifyAskMode :: Prompt => {
485+ inquire:: Confirm :: new ( & format ! (
486+ "Roll back to generation {}?" ,
487+ target_generation. number
488+ ) )
489+ . with_default ( false )
490+ . prompt ( ) ?
491+ } ,
492+ #[ cfg( all( unix, not( target_os = "macos" ) ) ) ]
493+ NotifyAskMode :: Notify => {
494+ NotificationSender :: new (
495+ "nh os rollback" ,
496+ & format ! ( "Roll back to generation {}?" , target_generation. number) ,
497+ )
498+ . ask ( )
499+ } ,
500+ } ;
475501
476502 if !confirmation {
477503 bail ! ( "User rejected the rollback" ) ;
@@ -659,7 +685,7 @@ fn print_vm_instructions(out_path: &Path) {
659685 }
660686}
661687
662- /// Runs the built NixOS VM by executing the VM runner script.
688+ /// Runs the built ` NixOS` VM by executing the VM runner script.
663689///
664690/// Locates the VM runner script in the build output directory and executes it,
665691/// streaming its output to the user. Returns an error if the script cannot be
0 commit comments