diff --git a/Cargo.lock b/Cargo.lock index 0111823..9c93052 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -912,9 +912,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "lazy_static" @@ -933,9 +933,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.164" +version = "0.2.165" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" +checksum = "fcb4d3d38eab6c5239a362fa8bae48c03baf980a6e7079f063942d563ef3533e" [[package]] name = "libloading" @@ -1353,9 +1353,9 @@ dependencies = [ [[package]] name = "rsa" -version = "0.9.6" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0e5124fcb30e76a7e79bfee683a2746db83784b86289f6251b54b7950a0dfc" +checksum = "47c75d7c5c6b673e58bf54d8544a9f432e3a925b0e80f7cd3602ab5c50c55519" dependencies = [ "const-oid", "digest", @@ -1822,9 +1822,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", ] @@ -1887,7 +1887,7 @@ dependencies = [ [[package]] name = "vaultix" -version = "0.1.4" +version = "0.1.6" dependencies = [ "age", "argh", diff --git a/Cargo.toml b/Cargo.toml index 3b1394c..398a5ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ cargo-features = ["edition2024"] [package] name = "vaultix" -version = "0.1.4" +version = "0.1.6" edition = "2024" [lib] diff --git a/src/cmd/renc.rs b/src/cmd/renc.rs index 54c314c..f77ed16 100644 --- a/src/cmd/renc.rs +++ b/src/cmd/renc.rs @@ -1,11 +1,10 @@ use crate::{ - interop::add_to_store, parser::identity::{ParsedIdentity, RawIdentity}, profile::Profile, util::secmap::{RencBuilder, RencCtx}, }; use eyre::{Result, bail}; -use log::{error, info}; +use log::error; use std::{fs, path::PathBuf}; pub struct CompleteProfile<'a>(pub Vec<&'a Profile>); @@ -61,21 +60,6 @@ impl<'a> CompleteProfile<'a> { let ctx = RencCtx::create(&self); - raw_instance - .build_instance() - .makeup(&ctx, identity)? - .iter() - .try_for_each(|p| { - let cache = p.canonicalize()?; - info!("storing cache: {}", cache.display()); - let o = add_to_store(cache)?; - if !o.status.success() { - error!("Command executed with failing error code"); - // Another side, calculate with nix `builtins.path` and pass to when deploy as `storage` - info!("path added to store: {}", String::from_utf8(o.stdout)?); - bail!("unexpected error"); - } - Ok(()) - }) + raw_instance.build_instance().makeup(&ctx, identity) } } diff --git a/src/interop/mod.rs b/src/interop/mod.rs deleted file mode 100644 index 886974a..0000000 --- a/src/interop/mod.rs +++ /dev/null @@ -1,41 +0,0 @@ -use std::{ - fmt::Display, - path::Path, - process::{Command, Output}, -}; - -use eyre::{eyre, Result}; - -pub fn add_to_store>(p: P) -> Result { - Command::new("nix") - .arg("store") - .arg("add-path") - .arg(p.as_ref()) - .output() - .map_err(|i| eyre!("nix cmd run failed {}", i)) -} - -macro_rules! eval_nix_command { - ($host:expr, $key:expr, $result_type:ty) => {{ - let cmd_output = Command::new("nix") - .arg("eval") - .arg(format!( - ".#nixosConfigurations.{}.config.vaultix.settings.{}", - $host, $key - )) - .output() - .map_err(|e| eyre::eyre!("nix cmd run failed: {}", e))? - .stdout; - - let res = serde_json::from_slice::<$result_type>(&cmd_output)?; - Ok(res) - }}; -} - -pub fn _eval_extra_recipient + Display>(host: H) -> Result> { - eval_nix_command!(host.as_ref(), "extraRecipients", Vec) -} - -pub fn _eval_host_pubkey + Display>(host: H) -> Result { - eval_nix_command!(host.as_ref(), "hostPubkey", String) -} diff --git a/src/main.rs b/src/main.rs index 3fd83ca..f930b2e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,6 @@ mod util { pub mod secmap; pub mod set_owner_group; } -mod interop; mod parser; mod profile; diff --git a/src/util/makeup.rs b/src/util/makeup.rs index 0fdc87e..eada24f 100644 --- a/src/util/makeup.rs +++ b/src/util/makeup.rs @@ -1,5 +1,4 @@ use std::{ - collections::HashSet, iter, path::PathBuf, rc::Rc, @@ -26,14 +25,10 @@ use super::{ secmap::{RencCtx, RencInstance}, }; -use eyre::{eyre, Context, ContextCompat, Result}; +use eyre::{Context, ContextCompat, Result, eyre}; impl<'a> RencInstance<'a> { - pub fn makeup( - self, - ctx_agenc: &RencCtx<'a, AgeEnc>, - ident: Box, - ) -> Result> { + pub fn makeup(self, ctx_agenc: &RencCtx<'a, AgeEnc>, ident: Box) -> Result<()> { let key: Rc = Rc::from(ident); let material = &self.inner().into_read_only(); @@ -176,16 +171,6 @@ impl<'a> RencInstance<'a> { } }); - Ok(last_res - .iter() - .filter(|i| i.is_ok()) - .map(|i| { - if let Ok(o) = i { - o.clone() - } else { - unreachable!() - } - }) - .collect()) + Ok(()) } }