Skip to content

Commit afa7439

Browse files
committed
Support adding extra ssh options on node configurations
1 parent c84ccd0 commit afa7439

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

src/nix/hive/options.nix

+7
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,13 @@ with builtins; rec {
208208
type = types.listOf types.str;
209209
default = [ "sudo" "-H" "--" ];
210210
};
211+
sshOptions = lib.mkOption {
212+
description = mdDoc ''
213+
Extra SSH options to pass to the SSH command.
214+
'';
215+
type = types.listOf types.str;
216+
default = [];
217+
};
211218
};
212219
};
213220
};

src/nix/host/ssh.rs

+9
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ pub struct Ssh {
3333
/// Command to elevate privileges with.
3434
privilege_escalation_command: Vec<String>,
3535

36+
/// extra SSH options
37+
extra_ssh_options: Vec<String>,
38+
3639
/// Whether to use the experimental `nix copy` command.
3740
use_nix3_copy: bool,
3841

@@ -189,6 +192,7 @@ impl Ssh {
189192
port: None,
190193
ssh_config: None,
191194
privilege_escalation_command: Vec::new(),
195+
extra_ssh_options: Vec::new(),
192196
use_nix3_copy: false,
193197
job: None,
194198
}
@@ -206,6 +210,10 @@ impl Ssh {
206210
self.privilege_escalation_command = command;
207211
}
208212

213+
pub fn set_extra_ssh_options(&mut self, options: Vec<String>) {
214+
self.extra_ssh_options = options;
215+
}
216+
209217
pub fn set_use_nix3_copy(&mut self, enable: bool) {
210218
self.use_nix3_copy = enable;
211219
}
@@ -346,6 +354,7 @@ impl Ssh {
346354
]
347355
.iter()
348356
.map(|s| s.to_string())
357+
.chain(self.extra_ssh_options.clone())
349358
.collect();
350359

351360
if let Some(port) = self.port {

src/nix/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ pub struct NodeConfig {
7878
#[serde(rename = "privilegeEscalationCommand")]
7979
privilege_escalation_command: Vec<String>,
8080

81+
#[serde(rename = "sshOptions")]
82+
extra_ssh_options: Vec<String>,
83+
8184
#[validate(custom = "validate_keys")]
8285
keys: HashMap<String, Key>,
8386
}
@@ -181,6 +184,7 @@ impl NodeConfig {
181184
self.target_host.as_ref().map(|target_host| {
182185
let mut host = Ssh::new(self.target_user.clone(), target_host.clone());
183186
host.set_privilege_escalation_command(self.privilege_escalation_command.clone());
187+
host.set_extra_ssh_options(self.extra_ssh_options.clone());
184188

185189
if let Some(target_port) = self.target_port {
186190
host.set_port(target_port);

src/nix/node_filter.rs

+1
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ mod tests {
248248
build_on_target: false,
249249
replace_unknown_profiles: false,
250250
privilege_escalation_command: vec![],
251+
extra_ssh_options: vec![],
251252
keys: HashMap::new(),
252253
};
253254

0 commit comments

Comments
 (0)