From 580616a8128fab968d4e85cfc36441f9f4b0904d Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Fri, 25 Nov 2022 14:50:07 -0800 Subject: feat(tvix/eval): implement equality on derivations Change-Id: I344b66c39cbc4b426accc482aa8f6f2eb18db68a Reviewed-on: https://cl.tvl.fyi/c/depot/+/7417 Autosubmit: Adam Joseph Reviewed-by: tazjin Tested-by: BuildkiteCI --- tvix/eval/src/vm.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs index f7c9a9dd78..f6605940a3 100644 --- a/tvix/eval/src/vm.rs +++ b/tvix/eval/src/vm.rs @@ -477,6 +477,38 @@ impl<'o> VM<'o> { } } allow_pointer_equality_on_functions_and_thunks = true; + match (a1.select("type"), a2.select("type")) { + (Some(v1), Some(v2)) + if "derivation" + == fallible!( + self, + v1.coerce_to_string(CoercionKind::ThunksOnly, self) + ) + .as_str() + && "derivation" + == fallible!( + self, + v2.coerce_to_string(CoercionKind::ThunksOnly, self) + ) + .as_str() => + { + if fallible!( + self, + a1.select("outPath") + .expect("encountered a derivation with no `outPath` attribute!") + .coerce_to_string(CoercionKind::ThunksOnly, self) + ) == fallible!( + self, + a2.select("outPath") + .expect("encountered a derivation with no `outPath` attribute!") + .coerce_to_string(CoercionKind::ThunksOnly, self) + ) { + continue; + } + break false; + } + _ => {} + } let iter1 = unwrap_or_clone_rc(a1).into_iter_sorted(); let iter2 = unwrap_or_clone_rc(a2).into_iter_sorted(); if iter1.len() != iter2.len() { -- cgit 1.4.1