diff --git a/README.md b/README.md index c353203..00fcaee 100644 --- a/README.md +++ b/README.md @@ -208,6 +208,10 @@ This is a set of options that can be put in any of the above definitions, with t # This defaults to `false` fastConnection = false; + # Use SSH gzip compress for `nix copy`. + # This defaults to `false` + compress = true; + # If the previous profile should be re-activated if activation fails. # This defaults to `true` autoRollback = true; diff --git a/examples/system/flake.nix b/examples/system/flake.nix index d8a19bf..d8f1f24 100644 --- a/examples/system/flake.nix +++ b/examples/system/flake.nix @@ -26,6 +26,7 @@ sshOpts = [ "-p" "2221" ]; hostname = "localhost"; fastConnection = true; + compress = true; interactiveSudo = true; profiles = { system = { diff --git a/interface.json b/interface.json index a96d1c2..35b702e 100644 --- a/interface.json +++ b/interface.json @@ -21,6 +21,9 @@ "fastConnection": { "type": "boolean" }, + "compress": { + "type": "boolean" + }, "autoRollback": { "type": "boolean" }, diff --git a/src/cli.rs b/src/cli.rs index f3bce4d..eeeecf4 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -70,6 +70,9 @@ pub struct Opts { /// Override the SSH options used #[clap(long, allow_hyphen_values = true)] ssh_opts: Option, + /// Override the SSH compression when using `nix copy` + #[clap(long)] + compress: Option, /// Override if the connecting to the target node should be considered fast #[clap(long)] fast_connection: Option, @@ -687,6 +690,7 @@ pub async fn run(args: Option<&ArgMatches>) -> Result<(), RunError> { profile_user: opts.profile_user, ssh_opts: opts.ssh_opts, fast_connection: opts.fast_connection, + compress: opts.compress, auto_rollback: opts.auto_rollback, hostname: opts.hostname, magic_rollback: opts.magic_rollback, diff --git a/src/data.rs b/src/data.rs index 12b0f01..7679f0e 100644 --- a/src/data.rs +++ b/src/data.rs @@ -19,6 +19,8 @@ pub struct GenericSettings { )] #[merge(strategy = merge::vec::append)] pub ssh_opts: Vec, + #[serde(rename(deserialize = "compress"))] + pub compress: Option, #[serde(rename(deserialize = "fastConnection"))] pub fast_connection: Option, #[serde(rename(deserialize = "autoRollback"))] diff --git a/src/lib.rs b/src/lib.rs index 61fac6a..4298d06 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -157,6 +157,7 @@ pub struct CmdOverrides { pub ssh_user: Option, pub profile_user: Option, pub ssh_opts: Option, + pub compress: Option, pub fast_connection: Option, pub auto_rollback: Option, pub hostname: Option, @@ -439,6 +440,9 @@ pub fn make_deploy_data<'a, 's>( if let Some(fast_connection) = cmd_overrides.fast_connection { merged_settings.fast_connection = Some(fast_connection); } + if let Some(compress) = cmd_overrides.compress { + merged_settings.compress = Some(compress); + } if let Some(auto_rollback) = cmd_overrides.auto_rollback { merged_settings.auto_rollback = Some(auto_rollback); } diff --git a/src/push.rs b/src/push.rs index 864c336..844949c 100644 --- a/src/push.rs +++ b/src/push.rs @@ -322,9 +322,11 @@ pub async fn push_profile(data: PushProfileData<'_>) -> Result<(), PushProfileEr None => &data.deploy_data.node.node_settings.hostname, }; + let compress = data.deploy_data.merged_settings.compress.unwrap_or_else(|| false); + let copy_exit_status = copy_command .arg("--to") - .arg(format!("ssh://{}@{}", data.deploy_defs.ssh_user, hostname)) + .arg(format!("ssh://{}@{}?compress={}", data.deploy_defs.ssh_user, hostname, compress)) .arg(&data.deploy_data.profile.profile_settings.path) .env("NIX_SSHOPTS", ssh_opts_str) .status()