fix(image-spec): discover transitive nix flake path deps from flake.lock#46
Open
sammiphone6 wants to merge 2 commits intomasterfrom
Open
fix(image-spec): discover transitive nix flake path deps from flake.lock#46sammiphone6 wants to merge 2 commits intomasterfrom
sammiphone6 wants to merge 2 commits intomasterfrom
Conversation
When a direct flake path input (e.g. minos2_rust) depends on another path input (e.g. rust-exautils), that transitive dependency only appears in flake.lock, not in the top-level flake.nix. The builder previously only scanned flake.nix for path inputs, causing Docker builds to fail with missing flake.nix errors for transitive deps. Add discover_nix_flake_lock_path_inputs() to scan flake.lock for all nodes with type=path, deduplicating against already-discovered direct inputs. Both the builder copy logic and the tag hash computation now include transitive path deps. Co-Authored-By: Samuel Mitchell <sammiphone6@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Nix resolves transitive dep paths relative to the parent input, not the root flake. Since all inputs are copied preserving their git-root- relative structure under local_packages/, the relative paths between parent and child inputs remain correct. Only direct inputs (from flake.nix) need path rewriting. Refactor copy logic into _copy_nix_input() helper for clarity. Co-Authored-By: Samuel Mitchell <sammiphone6@gmail.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.
Why are the changes needed?
When a direct nix flake path input (e.g.
minos2_rust) itself depends on another path input (e.g.rust-exautils), that transitive dependency only appears inflake.lock, not in the top-levelflake.nix. The builder previously only scannedflake.nixforurl = "path:..."patterns, so transitive path deps were never copied into the Docker build context. This caused Docker/nix builds to fail with errors like:What changes were proposed in this pull request?
New function
discover_nix_flake_lock_path_inputs()inimage_spec.py: Scansflake.lockJSON for all nodes with"type": "path"in theirlockedfield, deduplicating against already-discovered direct inputs.Updated
_copy_local_packages_and_update_lock()indefault_builder.py:flake.nix, also discovers transitive ones fromflake.lock.local_packages/AND paths rewritten in bothflake.nixandflake.lock.local_packages/— their paths inflake.lockare not rewritten. This is because nix resolves transitive dep paths relative to the parent input, not the root flake. Since both parent and child are copied preserving their git-root-relative structure underlocal_packages/, the relative paths between them remain correct._copy_nix_input()helper.Updated
taghash computation inImageSpec.tag: Includes transitive path deps in the content hash so image tags change when transitive deps change.How was this patch tested?
Manually verified against the
exa_mlflake which has the dependency chainexa_ml → minos2_rust → rust-exautilswhererust-exautilsis a transitive path dep that was previously missed.Initial version rewrote transitive dep paths in the top-level
flake.lock, which caused nix to resolve them relative to the parent input's new location, producing incorrect paths like:Fixed by not rewriting transitive dep paths — the relative structure is preserved by the copy layout.
No unit tests added yet.
Human review checklist
discover_nix_flake_lock_path_inputssilently skips paths that don't exist on disk, while direct inputs in the builder raiseValueError. Is this asymmetry intentional/acceptable?already_discoveredset mutation: The function mutates the caller's set as a side effect. Acceptable here but worth noting.local_packages/preserving their original git-root-relative paths. If a transitive dep lives outside the git root, this could break.discover_nix_flake_lock_path_inputsand the copy-without-rewrite behavior for transitive deps should have test coverage.Check all the applicable boxes
Link to Devin run: https://app.devin.ai/sessions/ca581679e9554604bfc845afc7f50f97
Requested by: @sammiphone6