aboutsummaryrefslogtreecommitdiff
path: root/src/cli.rs
diff options
context:
space:
mode:
authorMaximilian Bosch2022-10-09 18:37:10 +0200
committerMaximilian Bosch2022-10-09 18:47:08 +0200
commit068372aad18f04122bbdb836e36c655c157ebe71 (patch)
treea32513f56334765e68c64a680f0acb6e67f0ecb5 /src/cli.rs
parent41f15759dd8b638e7b4f299730d94d5aa46ab7eb (diff)
Add new activation strategy `boot` as equivalent to `nixos-rebuild boot`
This can be useful when e.g. deploying a kernel update to a target host. You usually plan a reboot (or kexec) after that to activate the new kernel. However you don't want to wait for services to be restarted first since these will be "restarted" anyways on the reboot. In cases like GitLab or the Atlassian stack this actually makes a difference. This patch changes the following things: * If `--boot` is provided, `nix-env -p profile-to-activate --set` is called for each deployed profile to make sure that it is activated automatically after a reboot. * However, the actual activation (e.g. `switch-to-configuration switch`) is skipped. Instead: * For NixOS, `switch-to-configuration boot` is called to set the new profile as default in the bootloader. * For everything else, nothing else is done. The profile is already the new default (and thus picked up on the next boot).
Diffstat (limited to 'src/cli.rs')
-rw-r--r--src/cli.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/cli.rs b/src/cli.rs
index cc5a3ac..eb9094d 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -86,6 +86,9 @@ pub struct Opts {
/// Show what will be activated on the machines
#[clap(long)]
dry_activate: bool,
+ /// Don't activate, but update the boot loader to boot into the new profile
+ #[clap(long)]
+ boot: bool,
/// Revoke all previously succeeded deploys when deploying multiple profiles
#[clap(long)]
rollback_succeeded: Option<bool>,
@@ -409,6 +412,7 @@ async fn run_deploy(
extra_build_args: &[String],
debug_logs: bool,
dry_activate: bool,
+ boot: bool,
log_dir: &Option<String>,
rollback_succeeded: bool,
) -> Result<(), RunDeployError> {
@@ -560,7 +564,7 @@ async fn run_deploy(
// Rollbacks adhere to the global seeting to auto_rollback and secondary
// the profile's configuration
for (_, deploy_data, deploy_defs) in &parts {
- if let Err(e) = deploy::deploy::deploy_profile(deploy_data, deploy_defs, dry_activate).await
+ if let Err(e) = deploy::deploy::deploy_profile(deploy_data, deploy_defs, dry_activate, boot).await
{
error!("{}", e);
if dry_activate {
@@ -617,6 +621,10 @@ pub async fn run(args: Option<&ArgMatches>) -> Result<(), RunError> {
&deploy::LoggerType::Deploy,
)?;
+ if opts.dry_activate && opts.boot {
+ error!("Cannot use both --dry-activate & --boot!");
+ }
+
let deploys = opts
.clone()
.targets
@@ -666,6 +674,7 @@ pub async fn run(args: Option<&ArgMatches>) -> Result<(), RunError> {
&opts.extra_build_args,
opts.debug_logs,
opts.dry_activate,
+ opts.boot,
&opts.log_dir,
opts.rollback_succeeded.unwrap_or(true),
)