aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authornotgne22020-10-23 22:44:52 -0700
committernotgne22020-10-23 22:44:52 -0700
commit72b066b293befec048f6a1b2f8d7a4b103ae4edf (patch)
tree620f9ff02ef16b0a6f45968a533b2c6ceb14bb93 /src/utils
parent4084e0516d3903acd80ca465f9906e5d3bce2659 (diff)
Add an option to keep build results
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/push.rs43
1 files changed, 30 insertions, 13 deletions
diff --git a/src/utils/push.rs b/src/utils/push.rs
index a82c9d4..5e87d5c 100644
--- a/src/utils/push.rs
+++ b/src/utils/push.rs
@@ -11,25 +11,27 @@ pub async fn push_profile(
repo: &str,
deploy_data: &super::DeployData<'_>,
deploy_defs: &super::DeployDefs<'_>,
+ keep_result: bool,
+ result_path: Option<&str>,
) -> Result<(), Box<dyn std::error::Error>> {
info!(
"Building profile `{}` for node `{}`",
deploy_data.profile_name, deploy_data.node_name
);
- let build_exit_status = if supports_flakes {
+ let mut build_c = if supports_flakes {
Command::new("nix")
- .arg("build")
- .arg("--no-link")
- .arg(format!(
- "{}#deploy.nodes.{}.profiles.{}.path",
- repo, deploy_data.node_name, deploy_data.profile_name
- ))
- .stdout(Stdio::null())
- .status()
- .await?
} else {
Command::new("nix-build")
+ };
+
+ let mut build_command = if supports_flakes {
+ build_c.arg("build").arg("--no-link").arg(format!(
+ "{}#deploy.nodes.{}.profiles.{}.path",
+ repo, deploy_data.node_name, deploy_data.profile_name
+ ))
+ } else {
+ build_c
.arg(&repo)
.arg("--no-out-link")
.arg("-A")
@@ -37,11 +39,26 @@ pub async fn push_profile(
"deploy.nodes.{}.profiles.{}.path",
deploy_data.node_name, deploy_data.profile_name
))
- .stdout(Stdio::null())
- .status()
- .await?
};
+ build_command = match (keep_result, supports_flakes) {
+ (true, _) => {
+ let result_path = match result_path {
+ Some(x) => x,
+ None => "./.deploy-gc",
+ };
+
+ build_command.arg("--out-link").arg(format!(
+ "{}/{}/{}",
+ result_path, deploy_data.node_name, deploy_data.profile_name
+ ))
+ }
+ (false, false) => build_command.arg("--no-out-link"),
+ (false, true) => build_command.arg("--no-link"),
+ };
+
+ let build_exit_status = build_command.stdout(Stdio::null()).status().await?;
+
if !build_exit_status.success() {
good_panic!("`nix build` failed");
}