about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2025-01-01T15·41+0100
committerclbot <clbot@tvl.fyi>2025-01-01T16·10+0000
commitbd73dff0bfd03a411c27193487bdeebf987ccbc7 (patch)
tree3652abd6defee47dd911c3bc18891175c922b4a6
parent5a50b39d76816e407b95895d3a50c9ae9e260f92 (diff)
fix(nix-compat): support Deriver: unknown-deriver NARInfos r/9056
According to https://github.com/NixOS/nix/commit/c60715e937e3773bbb8a114fc9b9c6577f8c5cb5,
these were produced by a legacy tool and should be considered as if
Deriver was not passed at all.

See: https://github.com/kalbasit/ncps/issues/171
Reported-In: https://github.com/nix-community/go-nix/pull/128
Change-Id: If285a11c3275cb3c857c68782bd13473c46f04bf
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12940
Reviewed-by: edef <edef@edef.eu>
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
-rw-r--r--tvix/nix-compat/src/narinfo/mod.rs30
1 files changed, 29 insertions, 1 deletions
diff --git a/tvix/nix-compat/src/narinfo/mod.rs b/tvix/nix-compat/src/narinfo/mod.rs
index 35146a927b39..151fbdcff24f 100644
--- a/tvix/nix-compat/src/narinfo/mod.rs
+++ b/tvix/nix-compat/src/narinfo/mod.rs
@@ -84,6 +84,9 @@ bitflags! {
         // Format quirks encountered in the cache.nixos.org dataset
         const REFERENCES_OUT_OF_ORDER = 1 << 2;
         const NAR_HASH_HEX = 1 << 3;
+
+        /// Deriver: unknown-deriver, produced by a legacy tool
+        const EXPLICIT_UNKNOWN_DERIVER = 1 << 4;
     }
 }
 
@@ -241,7 +244,11 @@ impl<'a> NarInfo<'a> {
                             }
                         }
                         None => {
-                            return Err(Error::InvalidDeriverStorePathMissingSuffix);
+                            if val == "unknown-deriver" {
+                                flags |= Flags::EXPLICIT_UNKNOWN_DERIVER;
+                            } else {
+                                return Err(Error::InvalidDeriverStorePathMissingSuffix);
+                            }
                         }
                     };
                 }
@@ -526,6 +533,27 @@ Sig: cache.nixos.org-1:92fl0i5q7EyegCj5Yf4L0bENkWuVAtgveiRcTEEUH0P6HvCE1xFcPbz/0
     }
 
     #[test]
+    fn explicit_unknown_deriver() {
+        // This is a NARInfo "produced by a legacy tool" according to Nix commit
+        // c60715e937e3773bbb8a114fc9b9c6577f8c5cb5
+        let parsed = NarInfo::parse(r#"StorePath: /nix/store/00bgd045z0d4icpbc2yyz4gx48ak44la-net-tools-1.60_p20170221182432
+URL: nar/1094wph9z4nwlgvsd53abfz8i117ykiv5dwnq9nnhz846s7xqd7d.nar.xz
+Compression: xz
+FileHash: sha256:1094wph9z4nwlgvsd53abfz8i117ykiv5dwnq9nnhz846s7xqd7d
+FileSize: 114980
+NarHash: sha256:0lxjvvpr59c2mdram7ympy5ay741f180kv3349hvfc3f8nrmbqf6
+NarSize: 464152
+References: 7gx4kiv5m0i7d7qkixq2cwzbr10lvxwc-glibc-2.27
+Deriver: unknown-deriver
+Sig: cache.nixos.org-1:sn5s/RrqEI+YG6/PjwdbPjcAC7rcta7sJU4mFOawGvJBLsWkyLtBrT2EuFt/LJjWkTZ+ZWOI9NTtjo/woMdvAg==
+Sig: hydra.other.net-1:JXQ3Z/PXf0EZSFkFioa4FbyYpbbTbHlFBtZf4VqU0tuMTWzhMD7p9Q7acJjLn3jofOtilAAwRILKIfVuyrbjAA==
+"#).expect("should parse");
+
+        assert!(parsed.flags.contains(Flags::EXPLICIT_UNKNOWN_DERIVER));
+        assert!(parsed.deriver.is_none());
+    }
+
+    #[test]
     fn nar_hash_hex() {
         let parsed = NarInfo::parse(r#"StorePath: /nix/store/0vpqfxbkx0ffrnhbws6g9qwhmliksz7f-perl-HTTP-Cookies-6.01
 URL: nar/1rv1m9inydm1r4krw8hmwg1hs86d0nxddd1pbhihx7l7fycjvfk3.nar.xz