Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ toml = "0.8"
whoami = "1.6"
yn = "0.1"
rpassword = "7.3.1"
shlex = "1.3.0"


[lib]
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,8 @@ pub fn make_deploy_data<'a, 's>(
merged_settings.user = cmd_overrides.profile_user.clone();
}
if let Some(ref ssh_opts) = cmd_overrides.ssh_opts {
merged_settings.ssh_opts = ssh_opts.split(' ').map(|x| x.to_owned()).collect();
merged_settings.ssh_opts =
shlex::split(ssh_opts).unwrap_or(ssh_opts.split(' ').map(|x| x.to_owned()).collect());
}
if let Some(fast_connection) = cmd_overrides.fast_connection {
merged_settings.fast_connection = Some(fast_connection);
Expand Down
30 changes: 19 additions & 11 deletions src/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,15 @@ pub async fn build_profile_remotely(data: &PushProfileData<'_>, derivation_name:
};
let store_address = format!("ssh-ng://{}@{}", data.deploy_defs.ssh_user, hostname);

let ssh_opts_str = data.deploy_data.merged_settings.ssh_opts.join(" ");

let ssh_opts_str = shlex::try_join(
data.deploy_data
.merged_settings
.ssh_opts
.iter()
.map(String::as_str)
.collect::<Vec<&str>>(),
)
.unwrap_or(data.deploy_data.merged_settings.ssh_opts.join(" "));

// copy the derivation to remote host so it can be built there
let copy_command_status = Command::new("nix")
Expand Down Expand Up @@ -289,15 +296,16 @@ pub async fn build_profile(data: PushProfileData<'_>) -> Result<(), PushProfileE
}

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(" ");
let ssh_opts_str = shlex::try_join(
data.deploy_data
.merged_settings
.ssh_opts
.iter()
.map(String::as_str)
.collect::<Vec<&str>>(),
)
.unwrap_or(data.deploy_data.merged_settings.ssh_opts.join(" "));


// remote building guarantees that the resulting derivation is stored on the target system
// no need to copy after building
Expand Down