aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornotgne22020-10-01 12:43:33 -0700
committernotgne22020-10-01 12:43:33 -0700
commitea5aab76849ba3ce9ff2b7eba2a391d4ea33fa3a (patch)
treef59aa113c111e87d0df9a3028a98ff6237177f0e /src
parent05a997558400f093c7278decd6300ce09044227b (diff)
Improve nix copy stuff
Diffstat (limited to 'src')
-rw-r--r--src/main.rs2
-rw-r--r--src/utils/deploy.rs26
-rw-r--r--src/utils/mod.rs24
-rw-r--r--src/utils/push.rs10
4 files changed, 33 insertions, 29 deletions
diff --git a/src/main.rs b/src/main.rs
index 75842e5..ba87e46 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -149,6 +149,8 @@ async fn get_deployment_data(
repo: &str,
extra_build_args: &[String],
) -> Result<utils::data::Data, Box<dyn std::error::Error>> {
+ info!("Evaluating flake in {}", repo);
+
let mut c = match supports_flakes {
true => Command::new("nix"),
false => Command::new("nix-instanciate"),
diff --git a/src/utils/deploy.rs b/src/utils/deploy.rs
index 9c258fd..1abae64 100644
--- a/src/utils/deploy.rs
+++ b/src/utils/deploy.rs
@@ -6,30 +6,6 @@ use super::data;
use tokio::process::Command;
-fn deploy_path_to_activate_path_str(
- deploy_path: &std::path::Path,
-) -> Result<String, Box<dyn std::error::Error>> {
- Ok(format!(
- "{}/activate",
- deploy_path
- .parent()
- .ok_or("Deploy path too short")?
- .to_str()
- .ok_or("Deploy path is not valid utf8")?
- .to_owned()
- ))
-}
-
-#[test]
-fn test_activate_path_generation() {
- match deploy_path_to_activate_path_str(&std::path::PathBuf::from(
- "/blah/blah/deploy-rs/bin/deploy",
- )) {
- Err(_) => panic!(""),
- Ok(x) => assert_eq!(x, "/blah/blah/deploy-rs/bin/activate".to_string()),
- }
-}
-
fn build_activate_command(
activate_path_str: String,
sudo: &Option<String>,
@@ -105,7 +81,7 @@ pub async fn deploy_profile(
profile_name, node_name
);
- let activate_path_str = deploy_path_to_activate_path_str(&deploy_data.current_exe)?;
+ let activate_path_str = super::deploy_path_to_activate_path_str(&deploy_data.current_exe)?;
let self_activate_command = build_activate_command(
activate_path_str,
diff --git a/src/utils/mod.rs b/src/utils/mod.rs
index 5802627..30201c3 100644
--- a/src/utils/mod.rs
+++ b/src/utils/mod.rs
@@ -136,3 +136,27 @@ pub async fn make_deploy_data<'a>(
current_exe,
})
}
+
+pub fn deploy_path_to_activate_path_str(
+ deploy_path: &std::path::Path,
+) -> Result<String, Box<dyn std::error::Error>> {
+ Ok(format!(
+ "{}/activate",
+ deploy_path
+ .parent()
+ .ok_or("Deploy path too short")?
+ .to_str()
+ .ok_or("Deploy path is not valid utf8")?
+ .to_owned()
+ ))
+}
+
+#[test]
+fn test_activate_path_generation() {
+ match deploy_path_to_activate_path_str(&std::path::PathBuf::from(
+ "/blah/blah/deploy-rs/bin/deploy",
+ )) {
+ Err(_) => panic!(""),
+ Ok(x) => assert_eq!(x, "/blah/blah/deploy-rs/bin/activate".to_string()),
+ }
+}
diff --git a/src/utils/push.rs b/src/utils/push.rs
index c87c32b..38a576f 100644
--- a/src/utils/push.rs
+++ b/src/utils/push.rs
@@ -66,7 +66,9 @@ pub async fn push_profile(
.arg("-k")
.arg(local_key)
.arg(&profile.profile_settings.path)
- .arg(&deploy_data.current_exe)
+ .arg(&super::deploy_path_to_activate_path_str(
+ &deploy_data.current_exe,
+ )?)
.stdout(Stdio::null())
.stderr(Stdio::null())
.spawn()?
@@ -101,10 +103,10 @@ pub async fn push_profile(
deploy_data.ssh_user, node.node_settings.hostname
))
.arg(&profile.profile_settings.path)
- .arg(&deploy_data.current_exe)
+ .arg(&super::deploy_path_to_activate_path_str(
+ &deploy_data.current_exe,
+ )?)
.env("NIX_SSHOPTS", ssh_opts_str)
- .stdout(Stdio::null())
- .stderr(Stdio::null())
.spawn()?
.await?;