about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tvix/nix-compat/src/narinfo/mod.rs27
-rw-r--r--tvix/store/src/proto/mod.rs5
2 files changed, 16 insertions, 16 deletions
diff --git a/tvix/nix-compat/src/narinfo/mod.rs b/tvix/nix-compat/src/narinfo/mod.rs
index 3fa73103bde6..8439403b59e9 100644
--- a/tvix/nix-compat/src/narinfo/mod.rs
+++ b/tvix/nix-compat/src/narinfo/mod.rs
@@ -53,7 +53,7 @@ pub struct NarInfo<'a> {
     // derivation metadata
     /// Nix system triple of [deriver]
     pub system: Option<&'a str>,
-    /// Store path of the derivation that produced this
+    /// Store path of the derivation that produced this. The last .drv suffix is stripped.
     pub deriver: Option<StorePathRef<'a>>,
     // cache-specific untrusted metadata
     /// Relative URL of the compressed NAR file
@@ -227,16 +227,19 @@ impl<'a> NarInfo<'a> {
                     }
                 }
                 "Deriver" => {
-                    let val = StorePathRef::from_bytes(val.as_bytes())
-                        .map_err(Error::InvalidDeriverStorePath)?;
-
-                    if !val.name().ends_with(".drv") {
-                        return Err(Error::InvalidDeriverStorePathMissingSuffix);
-                    }
-
-                    if deriver.replace(val).is_some() {
-                        return Err(Error::DuplicateField(tag.to_string()));
-                    }
+                    match val.strip_suffix(".drv") {
+                        Some(val) => {
+                            let val = StorePathRef::from_bytes(val.as_bytes())
+                                .map_err(Error::InvalidDeriverStorePath)?;
+
+                            if deriver.replace(val).is_some() {
+                                return Err(Error::DuplicateField(tag.to_string()));
+                            }
+                        }
+                        None => {
+                            return Err(Error::InvalidDeriverStorePathMissingSuffix);
+                        }
+                    };
                 }
                 "Sig" => {
                     let val = Signature::parse(val)
@@ -325,7 +328,7 @@ impl Display for NarInfo<'_> {
         writeln!(w)?;
 
         if let Some(deriver) = &self.deriver {
-            writeln!(w, "Deriver: {deriver}")?;
+            writeln!(w, "Deriver: {deriver}.drv")?;
         }
 
         if let Some(system) = self.system {
diff --git a/tvix/store/src/proto/mod.rs b/tvix/store/src/proto/mod.rs
index 558d7bc2831d..3e14f26e2761 100644
--- a/tvix/store/src/proto/mod.rs
+++ b/tvix/store/src/proto/mod.rs
@@ -212,10 +212,7 @@ impl From<&nix_compat::narinfo::NarInfo<'_>> for NarInfo {
             signatures,
             reference_names: value.references.iter().map(|r| r.to_string()).collect(),
             deriver: value.deriver.as_ref().map(|sp| StorePath {
-                // The parser already errors out with an error if the .drv suffix was missing,
-                // so you can only miss the suffix if you're manually constructing,
-                // which means we can unwrap here.
-                name: sp.name().strip_suffix(".drv").unwrap().to_owned(),
+                name: sp.name().to_owned(),
                 digest: Bytes::copy_from_slice(sp.digest()),
             }),
             ca,