From 3e2116f153077186556c01ae1fc89923abfea265 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 14 Nov 2026 03:45:10 +0000 Subject: populate: passage sources default identities_file when populate runs The default, toString ~/.passage/identities, is a path relative to the home directory, which Nix resolves when parsing the file defining it, populate's Nix library's types, so evaluating any sources failed in pure mode, e.g. in a flake. identities_file defaults to null, which leaves it out of the sources, and populate defaults it to ~/.passage/identities, in HOME, when it runs. The passage scenarios also run without identities_file, with HOME a directory that has .passage/identities. --- pkgs/populate/src/populate.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'pkgs/populate/src/populate.rs') 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, -- cgit v1.3.1