aboutsummaryrefslogtreecommitdiff
path: root/src/utils/push.rs
diff options
context:
space:
mode:
authornotgne22020-10-01 20:24:09 -0700
committernotgne22020-10-01 20:24:09 -0700
commit05803e0ebaf417d9ba40645b6548a48bf51f9213 (patch)
tree17af19223dd8b207e328ae1732fe0bf3078df5f6 /src/utils/push.rs
parente14acaf2bdc14bbdc30f3d558b62f64fe33ff5f9 (diff)
Handle more command exits correctly
Diffstat (limited to 'src/utils/push.rs')
-rw-r--r--src/utils/push.rs30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/utils/push.rs b/src/utils/push.rs
index 9a6748e..a973572 100644
--- a/src/utils/push.rs
+++ b/src/utils/push.rs
@@ -22,7 +22,7 @@ pub async fn push_profile(
deploy_data.profile_name, deploy_data.node_name
);
- if supports_flakes {
+ let build_exit_status = if supports_flakes {
Command::new("nix")
.arg("build")
.arg("--no-link")
@@ -32,8 +32,8 @@ pub async fn push_profile(
))
.stdout(Stdio::null())
.stderr(Stdio::null())
- .spawn()?
- .await?;
+ .status()
+ .await?
} else {
Command::new("nix-build")
.arg(&repo)
@@ -44,8 +44,12 @@ pub async fn push_profile(
))
.stdout(Stdio::null())
.stderr(Stdio::null())
- .spawn()?
- .await?;
+ .status()
+ .await?
+ };
+
+ if !build_exit_status.success() {
+ good_panic!("`nix build` failed");
}
if let Ok(local_key) = std::env::var("LOCAL_KEY") {
@@ -54,7 +58,7 @@ pub async fn push_profile(
deploy_data.profile_name, deploy_data.node_name
);
- Command::new("nix")
+ let sign_exit_status = Command::new("nix")
.arg("sign-paths")
.arg("-r")
.arg("-k")
@@ -65,8 +69,12 @@ pub async fn push_profile(
)?)
.stdout(Stdio::null())
.stderr(Stdio::null())
- .spawn()?
+ .status()
.await?;
+
+ if !sign_exit_status.success() {
+ good_panic!("`nix sign-paths` failed");
+ }
}
debug!(
@@ -99,7 +107,7 @@ pub async fn push_profile(
None => &deploy_data.node.node_settings.hostname,
};
- copy_command
+ let copy_exit_status = copy_command
.arg("--to")
.arg(format!("ssh://{}@{}", deploy_defs.ssh_user, hostname))
.arg(&deploy_data.profile.profile_settings.path)
@@ -107,8 +115,12 @@ pub async fn push_profile(
&deploy_defs.current_exe,
)?)
.env("NIX_SSHOPTS", ssh_opts_str)
- .spawn()?
+ .status()
.await?;
+ if !copy_exit_status.success() {
+ good_panic!("`nix copy` failed");
+ }
+
Ok(())
}