queue-runner: resolve dynamic derivation dependencies#1697
Merged
Ericson2314 merged 2 commits intoNixOS:masterfrom May 3, 2026
Merged
queue-runner: resolve dynamic derivation dependencies#1697Ericson2314 merged 2 commits intoNixOS:masterfrom
Ericson2314 merged 2 commits intoNixOS:masterfrom
Conversation
Replace the recursive SQL CTE in `resolve_drv_output_chains` (which cannot see the in-memory resolved-drv map) with a Rust loop that calls a new depth-1 `resolve_drv_output` query at each level, translating intermediate drv paths through `resolved_drv_map` between steps. This fixes resolution of dynamic derivation chains where an intermediate result is an unresolved drv (status=13): the recursive SQL required `status = 0` at every level and had no way to follow the in-memory mapping, so chains like `make-derivations.drv.drv^out^out` would fail when the intermediate `make-derivations.drv` had been resolved to a different path. Results are memoized in a temporary `HashMap` scoped to the `try_resolve` call, so repeated lookups of the same (drv, output_name) pair hit the cache. Once we have the resolved derivation mapping in the database, we can go back to the all-SQL approach, saving ourselves some app <-> DB round trips. This situation is explicitly tested.
Reverse dependencies now carry an `OutputNameChain` (empty for regular deps, non-empty for dynamic ones), stored in a unified `rdeps` list via `ReverseDep`. This replaces the previous `get_input_drvs` method with `input_drvs`, which walks `SingleDerivedPath` directly, skipping `Opaque` (source) inputs and returning only `Built` derivation dependencies with their relation chain. When a step completes and has dynamic reverse dependencies (`rdeps` with a non-empty `OutputNameChain`), pop one level from the relation, look up the produced output, and create a new step for the resulting derivation. This resolves dynamic derivation chains one level at a time as each step finishes, with no extra DB round-trip needed. The dyn-drv tests are re-enabled and updated to verify the full build step chains: 4 steps for simple dynamic derivations, 12 for the non-trivial DAG case. Co-Authored-By: Artemis Tosini <artemis.tosini@obsidian.systems> Co-Authored-By: John Ericson <John.Ericson@Obsidian.Systems> Co-Authored-By: Amaan Qureshi <git@amaanq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reverse dependencies now carry an
OutputNameChain(empty for regular deps, non-empty for dynamic ones), stored in a unifiedrdepslist viaReverseDep. This replaces the previousget_input_drvsmethod withinput_drvs, which walksSingleDerivedPathdirectly, skippingOpaque(source) inputs and returning onlyBuiltderivation dependencies with their relation chain.When a step completes and has dynamic reverse dependencies (
rdepswith a non-emptyOutputNameChain), pop one level from the relation, look up the produced output, and create a new step for the resulting derivation. This resolves dynamic derivation chains one level at a time as each step finishes, with no extra DB round-trip needed.The dyn-drv tests are re-enabled and updated to verify the full build step chains: 4 steps for simple dynamic derivations, 12 for the non-trivial DAG case.
The main work is from @artemist
Depends on #1629