about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
authorAdam Joseph <adam@westernsemico.com>2022-11-25T22·50-0800
committerclbot <clbot@tvl.fyi>2022-11-28T20·05+0000
commit580616a8128fab968d4e85cfc36441f9f4b0904d (patch)
treebf6ea788d97e27aad6b68d02fefbdeb1ff57b047 /tvix
parent7606e62a2ffa5db2b47b0a31f5a4642f303eda12 (diff)
feat(tvix/eval): implement equality on derivations r/5350
Change-Id: I344b66c39cbc4b426accc482aa8f6f2eb18db68a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7417
Autosubmit: Adam Joseph <adam@westernsemico.com>
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix')
-rw-r--r--tvix/eval/src/vm.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs
index f7c9a9dd7871..f6605940a38c 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() {