diff options
Diffstat (limited to 'pkgs/populate/src')
| -rw-r--r-- | pkgs/populate/src/check.rs | 2 | ||||
| -rw-r--r-- | pkgs/populate/src/populate.rs | 17 |
2 files changed, 13 insertions, 6 deletions
diff --git a/pkgs/populate/src/check.rs b/pkgs/populate/src/check.rs index 5b73deb..155565f 100644 --- a/pkgs/populate/src/check.rs +++ b/pkgs/populate/src/check.rs @@ -104,7 +104,7 @@ fn known_settings(kind: &str) -> &'static [(&'static str, Kind, bool)] { "passage" => &[ ("age", String, true), ("dir", String, true), - ("identities_file", String, true), + ("identities_file", String, false), ], "pipe" => &[("command", Absolute, true)], "symlink" => &[("target", String, true), ("inputs", Inputs, false)], diff --git a/pkgs/populate/src/populate.rs b/pkgs/populate/src/populate.rs index 47a9099..a488cfd 100644 --- a/pkgs/populate/src/populate.rs +++ b/pkgs/populate/src/populate.rs @@ -195,13 +195,20 @@ fn deliver( "passage" => { let host = context.target.host.split('.').next().unwrap_or_default(); let mut command = run::local_shell(sh::local::PASSAGE, &[host], &workdir); - for (variable, key) in [ - ("PASSAGE_AGE", "age"), - ("PASSAGE_DIR", "dir"), - ("PASSAGE_IDENTITIES_FILE", "identities_file"), - ] { + for (variable, key) in [("PASSAGE_AGE", "age"), ("PASSAGE_DIR", "dir")] { command.env(variable, string(settings, key)?); } + let identities = match settings.get("identities_file").and_then(Value::as_str) { + Some(file) => file.to_string(), + None => match std::env::var("HOME") { + Ok(home) if !home.is_empty() => format!("{home}/.passage/identities"), + _ => return Err(Failure::Message( + "populate: HOME isn't set, so the passage source has no identities_file" + .to_string(), + )), + }, + }; + command.env("PASSAGE_IDENTITIES_FILE", identities); run::status(&mut command)?; rsync::transfer( context, |
