Backward compatibility hack for getFlake applied to unsafeDiscardStringContext - #422
Conversation
📝 WalkthroughWalkthroughThe PR refactors Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/functional/flakes/get-flake.sh (1)
29-46: Consider adding a nested-path regression case.This only exercises the empty
subPath/ emptydircase. Since the new branch now composes both the store subpath andflakeRef.subdir, a/subflakeor?dir=subflakevariant would give much better coverage for path-joining regressions.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/functional/flakes/get-flake.sh` around lines 29 - 46, Add a nested-path regression case that exercises composing a store subpath with flakeRef.subdir: create a subdirectory (e.g., "$flake1Dir/subflake") containing a flake.nix that mirrors the original but uses builtins.unsafeDiscardStringContext with a path that includes the subpath (e.g., "path:/subflake:${self.sourceInfo}?narHash=${self.narHash}") or use the query form "?dir=subflake", then evaluate the nested flake (e.g., nix eval --raw "$flake1Dir/subflake#flakeOutputs.foo" or nix eval --raw "$flake1Dir?dir=subflake#flakeOutputs.foo") and assert it equals "bar" to cover the /subflake / ?dir=subflake variants alongside the existing empty-subPath case.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/functional/flakes/get-flake.sh`:
- Around line 29-46: Add a nested-path regression case that exercises composing
a store subpath with flakeRef.subdir: create a subdirectory (e.g.,
"$flake1Dir/subflake") containing a flake.nix that mirrors the original but uses
builtins.unsafeDiscardStringContext with a path that includes the subpath (e.g.,
"path:/subflake:${self.sourceInfo}?narHash=${self.narHash}") or use the query
form "?dir=subflake", then evaluate the nested flake (e.g., nix eval --raw
"$flake1Dir/subflake#flakeOutputs.foo" or nix eval --raw
"$flake1Dir?dir=subflake#flakeOutputs.foo") and assert it equals "bar" to cover
the /subflake / ?dir=subflake variants alongside the existing empty-subPath
case.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 04063b19-a31e-4b47-8911-c78283c724df
📒 Files selected for processing (2)
src/libflake/flake-primops.cctests/functional/flakes/get-flake.sh
This builds on top of #14050 to actually make flakes get lazily copied to the store. This repurposes a slightly less lazy (but also more deterministic) approach that determinate nix has taken. We do still pay to cost of hashing an input once to compute the store path and narHash daemon-client-side. This could be improved in follow-ups in case we don't actually need to check the narHash (like during local development). We need certain backwards compatibility hacks for getFlake with a discarded string context, those are similar to what detnix does. See: DeterminateSystems#422 See: DeterminateSystems#402 Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
This builds on top of #14050 to actually make flakes get lazily copied to the store. This repurposes a slightly less lazy (but also more deterministic) approach than determinate nix has taken. We do still pay to cost of hashing an input once to compute the store path and narHash daemon-client-side. This could be improved in follow-ups in case we don't actually need to check the narHash (like during local development). We need certain backwards compatibility hacks for getFlake with a discarded string context, those are similar to what detnix does. See: DeterminateSystems#422 See: DeterminateSystems#402 Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
This builds on top of #14050 to actually make flakes get lazily copied to the store. This repurposes a slightly less lazy (but also more deterministic) approach than determinate nix has taken. We do still pay to cost of hashing an input once to compute the store path and narHash daemon-client-side. This could be improved in follow-ups in case we don't actually need to check the narHash (like during local development). We need certain backwards compatibility hacks for getFlake with a discarded string context, those are similar to what detnix does. See: DeterminateSystems#422 See: DeterminateSystems#402 Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
This builds on top of #14050 to actually make flakes get lazily copied to the store. This repurposes a slightly less lazy (but also more deterministic) approach than determinate nix has taken. We do still pay to cost of hashing an input once to compute the store path and narHash daemon-client-side. This could be improved in follow-ups in case we don't actually need to check the narHash (like during local development). We need certain backwards compatibility hacks for getFlake with a discarded string context, those are similar to what detnix does. See: DeterminateSystems#422 See: DeterminateSystems#402 Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
This builds on top of #14050 to actually make flakes get lazily copied to the store. This repurposes a slightly less lazy (but also more deterministic) approach than determinate nix has taken. We do still pay to cost of hashing an input once to compute the store path and narHash daemon-client-side. This could be improved in follow-ups in case we don't actually need to check the narHash (like during local development). We need certain backwards compatibility hacks for getFlake with a discarded string context, those are similar to what detnix does. See: DeterminateSystems#422 See: DeterminateSystems#402 Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
This builds on top of NixOS#14050 to actually make flakes get lazily copied to the store. This repurposes a slightly less lazy (but also more deterministic) approach than determinate nix has taken. We do still pay to cost of hashing an input once to compute the store path and narHash daemon-client-side. This could be improved in follow-ups in case we don't actually need to check the narHash (like during local development). We need certain backwards compatibility hacks for getFlake with a discarded string context, those are similar to what detnix does. See: DeterminateSystems#422 See: DeterminateSystems#402 Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
Motivation
Similar to #402 but with a different kind of string context.
Context
Summary by CodeRabbit
Bug Fixes
builtins.getFlakewith path flake references, using a more direct store filesystem lookup approach.Tests
getFlakebackward compatibility when applied to store-path string contexts.