From 1f70de459d1ab8dbcfcf617cf03fe2549c0b3b4b Mon Sep 17 00:00:00 2001 From: edef Date: Mon, 24 Mar 2025 19:41:26 +0000 Subject: [PATCH] refactor(snix/nix-compat/derivation): minor cleanup Change-Id: I9c975b238e78dcee80412f01681108977f29082a Reviewed-on: https://cl.snix.dev/c/snix/+/30276 Tested-by: besadii Reviewed-by: Florian Klink --- snix/nix-compat/src/derivation/mod.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/snix/nix-compat/src/derivation/mod.rs b/snix/nix-compat/src/derivation/mod.rs index 43c9db2b5..fe92d9256 100644 --- a/snix/nix-compat/src/derivation/mod.rs +++ b/snix/nix-compat/src/derivation/mod.rs @@ -133,7 +133,7 @@ impl Derivation { name: &str, ) -> Result, DerivationError> { // append .drv to the name - let name = &format!("{}.drv", name); + let name = format!("{}.drv", name); // collect the list of paths from input_sources and input_derivations // into a (sorted, guaranteed by BTreeSet) list of references @@ -144,8 +144,8 @@ impl Derivation { .map(StorePath::to_absolute_path) .collect(); - build_text_path(name, self.to_aterm_bytes(), references) - .map_err(|_e| DerivationError::InvalidOutputName(name.to_string())) + build_text_path(&name, self.to_aterm_bytes(), references) + .map_err(|_e| DerivationError::InvalidOutputName(name)) } /// Returns the FOD digest, if the derivation is fixed-output, or None if @@ -159,7 +159,7 @@ impl Derivation { } let out_output = self.outputs.get("out")?; - let ca_hash = &out_output.ca_hash.as_ref()?; + let ca_hash = out_output.ca_hash.as_ref()?; Some( Sha256::new_with_prefix(format!( @@ -170,9 +170,7 @@ impl Derivation { .path .as_ref() .map(StorePath::to_absolute_path) - .as_ref() - .map(|s| s as &str) - .unwrap_or(""), + .unwrap_or_default(), )) .finalize() .into(),