From 75cc52ddb136e66b1a79117425fb35f80dcecc07 Mon Sep 17 00:00:00 2001 From: Ryan Lahfa Date: Sun, 14 Jan 2024 02:40:07 +0100 Subject: fix(tvix/eval): `getContext` merges underlying values Previously, we were assembling very naively an attribute set composed of context we saw. But it was forgetting that `"${drv}${drv.drvPath}"` would contain 2 contexts with the same key, but with different values, one with `outputs = [ "out" ];` and `allOutputs = true;`. Following this reasoning and comparing with what Nix does, we ought to merge underlying values systematically. Hence, I bring `itertools` to perform a group by on the key and merge everything on the fly, it's not beautiful but it's the best I could find, notice that I don't use `group_by` but I talk about group by, that is, because `group_by` is a `group_by_consecutive`, see https://github.com/rust-itertools/itertools/issues/374. Initially, I tried to do it without a `into_grouping_map_by`, it was akin to assemble the final `NixAttrs` directly, it was less readable and harder to pull out because we don't have a lot of in-place mutable functions on our data structures. Change-Id: I9933c9bd88ffe04de50dda14f21879b60d8b8cd4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10620 Tested-by: BuildkiteCI Reviewed-by: tazjin --- tvix/eval/Cargo.toml | 1 + 1 file changed, 1 insertion(+) (limited to 'tvix/eval/Cargo.toml') diff --git a/tvix/eval/Cargo.toml b/tvix/eval/Cargo.toml index d1bb48a7c5..d347d0ea68 100644 --- a/tvix/eval/Cargo.toml +++ b/tvix/eval/Cargo.toml @@ -16,6 +16,7 @@ codemap-diagnostic = "0.1.1" dirs = "4.0.0" genawaiter = { version = "0.99.1", default_features = false } imbl = { version = "2.0", features = [ "serde" ] } +itertools = "0.12.0" lazy_static = "1.4.0" lexical-core = { version = "0.8.5", features = ["format", "parse-floats"] } path-clean = "0.1" -- cgit 1.4.1