aboutsummaryrefslogtreecommitdiff
path: root/src/push.rs
diff options
context:
space:
mode:
author2xsaiko2022-12-29 16:19:59 +0100
committerGitHub2022-12-29 19:19:59 +0400
commita5619f5660a00f58c2b7c16d89058e92327ac9b8 (patch)
tree41b256c1a2184c1020c7c995e00f26724d3f7452 /src/push.rs
parent351352374c452de0378d6c22baf1745f02ae6c52 (diff)
Build every profile first, then push (#158)
Try to build everything first before pushing to remotes. Since the build is more likely to fail than the upload, if there is an error the deployment will fail sooner and before uploading any potentially unusable configuration.
Diffstat (limited to '')
-rw-r--r--src/push.rs33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/push.rs b/src/push.rs
index 0801bd9..6d9f10d 100644
--- a/src/push.rs
+++ b/src/push.rs
@@ -209,7 +209,7 @@ pub async fn build_profile_remotely(data: &PushProfileData<'_>, derivation_name:
Ok(())
}
-pub async fn push_profile(data: PushProfileData<'_>) -> Result<(), PushProfileError> {
+pub async fn build_profile(data: PushProfileData<'_>) -> Result<(), PushProfileError> {
debug!(
"Finding the deriver of store path for {}",
&data.deploy_data.profile.profile_settings.path
@@ -218,17 +218,6 @@ pub async fn push_profile(data: PushProfileData<'_>) -> Result<(), PushProfileEr
// `nix-store --query --deriver` doesn't work on invalid paths, so we parse output of show-derivation :(
let mut show_derivation_command = Command::new("nix");
- let ssh_opts_str = data
- .deploy_data
- .merged_settings
- .ssh_opts
- // This should provide some extra safety, but it also breaks for some reason, oh well
- // .iter()
- // .map(|x| format!("'{}'", x))
- // .collect::<Vec<String>>()
- .join(" ");
-
-
show_derivation_command
.arg("show-derivation")
.arg(&data.deploy_data.profile.profile_settings.path);
@@ -259,12 +248,28 @@ pub async fn push_profile(data: PushProfileData<'_>) -> Result<(), PushProfileEr
return Err(PushProfileError::RemoteBuildWithLegacyNix)
}
- // remote building guarantees that the resulting derivation is stored on the target system
- // no need to copy after building
build_profile_remotely(&data, derivation_name).await?;
} else {
build_profile_locally(&data, derivation_name).await?;
+ }
+
+ Ok(())
+}
+
+pub async fn push_profile(data: PushProfileData<'_>) -> Result<(), PushProfileError> {
+ let ssh_opts_str = data
+ .deploy_data
+ .merged_settings
+ .ssh_opts
+ // This should provide some extra safety, but it also breaks for some reason, oh well
+ // .iter()
+ // .map(|x| format!("'{}'", x))
+ // .collect::<Vec<String>>()
+ .join(" ");
+ // remote building guarantees that the resulting derivation is stored on the target system
+ // no need to copy after building
+ if !data.deploy_data.merged_settings.remote_build.unwrap_or(false) {
info!(
"Copying profile `{}` to node `{}`",
data.deploy_data.profile_name, data.deploy_data.node_name