diff options
author | Vova Kryachko <v.kryachko@gmail.com> | 2024-11-12T14·54-0500 |
---|---|---|
committer | Vladimir Kryachko <v.kryachko@gmail.com> | 2024-11-12T16·43+0000 |
commit | 6aada9106209d431407c3a45f466ef59b3cff504 (patch) | |
tree | 658d5a673f4f5011db4bebe1cc43aa37bfdeff02 /tvix/nix-compat/src/narinfo/signature.rs | |
parent | b1764e11092f7817633ae013508e6285585ac1cf (diff) |
feat(tvix-store): Improve tvix-store copy. r/8916
This change contains 2 improvements to the tvix-store copy command: 1. Allows reading the reference graph from stdin, using `-` argument 2. Supports json representation produced by `nix path-info --json` command. In general it makes is easier and faster to import arbitrary closures from an existing nix store with e.g the following command: ``` nix path-info ./result --json --closure-size --recursive | \ jq -s '{closure: add}' | \ tvix-store copy - ``` Change-Id: Id6eea2993da233ecfbdc186f1a8c37735b686264 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12765 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/nix-compat/src/narinfo/signature.rs')
-rw-r--r-- | tvix/nix-compat/src/narinfo/signature.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tvix/nix-compat/src/narinfo/signature.rs b/tvix/nix-compat/src/narinfo/signature.rs index 8df77019cd8f..2005a5cb60df 100644 --- a/tvix/nix-compat/src/narinfo/signature.rs +++ b/tvix/nix-compat/src/narinfo/signature.rs @@ -92,6 +92,12 @@ where bytes: self.bytes, } } + pub fn to_owned(&self) -> Signature<String> { + Signature { + name: self.name.to_string(), + bytes: self.bytes, + } + } } impl<'a, 'de, S> Deserialize<'de> for Signature<S> @@ -133,6 +139,16 @@ where } } +impl<S> std::hash::Hash for Signature<S> +where + S: AsRef<str>, +{ + fn hash<H: std::hash::Hasher>(&self, state: &mut H) { + state.write(self.name.as_ref().as_bytes()); + state.write(&self.bytes); + } +} + #[derive(Debug, thiserror::Error, PartialEq, Eq)] pub enum Error { #[error("Invalid name: {0}")] |