diff --git a/src/nix/hive/eval.nix b/src/nix/hive/eval.nix index 2c89d6f..d808f35 100644 --- a/src/nix/hive/eval.nix +++ b/src/nix/hive/eval.nix @@ -212,7 +212,7 @@ let }; }; - keyType = { lib, name, ... }: let + keyType = { lib, name, config, ... }: let inherit (lib) types; in { options = { @@ -255,7 +255,15 @@ let Destination directory on the host. ''; default = "/run/keys"; - type = types.str; + type = types.path; + }; + path = lib.mkOption { + description = '' + Full path to the destination. + ''; + default = "${config.destDir}/${config.name}"; + type = types.path; + internal = true; }; user = lib.mkOption { description = '' diff --git a/src/nix/host/local.rs b/src/nix/host/local.rs index e573da9..73b4be1 100644 --- a/src/nix/host/local.rs +++ b/src/nix/host/local.rs @@ -119,7 +119,7 @@ impl Local { } let path = key.path(); - let key_script = format!("'{}'", key_uploader::generate_script(key, &path, require_ownership)); + let key_script = format!("'{}'", key_uploader::generate_script(key, path, require_ownership)); let mut command = Command::new("sh"); diff --git a/src/nix/host/ssh.rs b/src/nix/host/ssh.rs index 6857338..35f28ef 100644 --- a/src/nix/host/ssh.rs +++ b/src/nix/host/ssh.rs @@ -220,7 +220,7 @@ impl Ssh { } let path = key.path(); - let key_script = key_uploader::generate_script(key, &path, require_ownership); + let key_script = key_uploader::generate_script(key, path, require_ownership); let mut command = self.ssh(&["sh", "-c", &key_script]); diff --git a/src/nix/key.rs b/src/nix/key.rs index 33d057c..3dc6953 100644 --- a/src/nix/key.rs +++ b/src/nix/key.rs @@ -91,6 +91,8 @@ pub enum UploadAt { pub struct Key { name: String, + path: PathBuf, + #[serde(flatten)] source: KeySource, @@ -146,7 +148,7 @@ impl Key { } } - pub fn path(&self) -> PathBuf { self.dest_dir.join(&self.name) } + pub fn path(&self) -> &Path { &self.path } pub fn user(&self) -> &str { &self.user } pub fn group(&self) -> &str { &self.group } pub fn permissions(&self) -> &str { &self.permissions }