Skip to content

Support flake-schemas 0.3.0#8

Open
gustavderdrache wants to merge 1 commit intomainfrom
gustavderdrache/flake-schemas-0.3
Open

Support flake-schemas 0.3.0#8
gustavderdrache wants to merge 1 commit intomainfrom
gustavderdrache/flake-schemas-0.3

Conversation

@gustavderdrache
Copy link

@gustavderdrache gustavderdrache commented Mar 3, 2026

This required updating to use the new derivationAttrPath instead of derivation.

I've tested with both the 0.1.4 version and the latest, but I've kept the version bump since we might as well.

Summary by CodeRabbit

  • Chores
    • Improved internal path resolution and attribute navigation mechanisms
    • Enhanced output processing and derivation path handling
    • Refined filtering logic for nested attribute traversal
    • Updated infrastructure configuration dependencies

This required updating to use the new `derivationAttrPath` instead of
`derivation`.
@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

📝 Walkthrough

Walkthrough

Refactors flake.nix to improve nested attribute traversal and derivation path handling. Introduces a new getAttrFromPath helper function, updates a pinned dependency URL, restructures inventoryFor to support multi-step nested filtering, and reworks output path resolution to use path-based derivations with fallback behavior.

Changes

Cohort / File(s) Summary
Helper Function & Core Refactoring
flake.nix
Adds getAttrFromPath helper for nested attribute navigation. Refactors inventoryFor to consistently use multi-step filter paths with child attribute traversal. Reworks doFilter to propagate output context through recursive filtering and updates output path resolution to pull from drv.outputs or fallback to null when drv is unavailable. Updates flakeSchemasFlakePinned URL to newer version.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 Nested paths through attributes deep,
A helper function to guide the way,
Refactored flows with filtering's keep,
Outputs now resolved in style and play,
Derivations dance with context new—
The warren's logic, fresh and true!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'Support flake-schemas 0.3.0' clearly and directly summarizes the main change: upgrading support for the flake-schemas library to version 0.3.0.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch gustavderdrache/flake-schemas-0.3

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@flake.nix`:
- Around line 91-111: The code dereferences attrs.derivationAttrPath,
attrs.derivation and fields on drv (drv.drvPath, drv.outputs,
drv.${outputName}.outPath) without guarding, which can throw and make
includingOutputPaths fail; fix by validating before access (e.g. use
builtins.hasAttr / builtins.tryEval or builtins.isDerivation where available) so
drv is only treated as a derivation when it actually has drvPath and outputs,
and when mapping outputs check each outputName exists on drv before reading
drv.${outputName}.outPath; update the branches that compute drv and the
derivation/outputs results to return null/nullable metadata when validation
fails instead of performing direct dereferences.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7f0275a and bbffd67.

📒 Files selected for processing (1)
  • flake.nix

Comment on lines +91 to +111
drv =
if attrs?derivationAttrPath
then getAttrFromPath attrs.derivationAttrPath output
# TODO: remove when no longer needed
else if attrs?derivation
then attrs.derivation
else null;
in
{
derivation = if drv != null then drv.drvPath else null;
outputs =
if attrs ? derivation
then
if drv != null then
builtins.listToAttrs
(
builtins.map
(outputName:
{
name = outputName;
value = attrs.derivation.${outputName}.outPath;
}
)
attrs.derivation.outputs
)
else
null;
(outputName: {
name = outputName;
value = drv.${outputName}.outPath;
})
drv.outputs
) else null;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Guard derivation path dereferences to prevent full inventory evaluation failure.

Line 93, Line 100, and Line 108 can throw when a path is stale or resolves to a non-derivation value. That makes includingOutputPaths fail hard instead of returning nullable metadata for the problematic node.

🛡️ Suggested hardening patch
-                              drv =
-                                if attrs?derivationAttrPath
-                                then getAttrFromPath attrs.derivationAttrPath output
+                              drv =
+                                if attrs ? derivationAttrPath
+                                then try (getAttrFromPath attrs.derivationAttrPath output) null
                                 # TODO: remove when no longer needed
-                                else if attrs?derivation
+                                else if attrs ? derivation
                                 then attrs.derivation
                                 else null;
                             in
                             {
-                              derivation = if drv != null then drv.drvPath else null;
+                              derivation = try (if drv != null then drv.drvPath else null) null;
                               outputs =
-                                if drv != null then
-                                  builtins.listToAttrs
-                                    (
-                                      builtins.map
-                                        (outputName: {
-                                          name = outputName;
-                                          value = drv.${outputName}.outPath;
-                                        })
-                                        drv.outputs
-                                    ) else null;
+                                try (
+                                  if drv != null then
+                                    builtins.listToAttrs
+                                      (
+                                        builtins.map
+                                          (outputName: {
+                                            name = outputName;
+                                            value = drv.${outputName}.outPath;
+                                          })
+                                          drv.outputs
+                                      )
+                                  else null
+                                ) null;
                             }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
drv =
if attrs?derivationAttrPath
then getAttrFromPath attrs.derivationAttrPath output
# TODO: remove when no longer needed
else if attrs?derivation
then attrs.derivation
else null;
in
{
derivation = if drv != null then drv.drvPath else null;
outputs =
if attrs ? derivation
then
if drv != null then
builtins.listToAttrs
(
builtins.map
(outputName:
{
name = outputName;
value = attrs.derivation.${outputName}.outPath;
}
)
attrs.derivation.outputs
)
else
null;
(outputName: {
name = outputName;
value = drv.${outputName}.outPath;
})
drv.outputs
) else null;
drv =
if attrs ? derivationAttrPath
then try (getAttrFromPath attrs.derivationAttrPath output) null
# TODO: remove when no longer needed
else if attrs ? derivation
then attrs.derivation
else null;
in
{
derivation = try (if drv != null then drv.drvPath else null) null;
outputs =
try (
if drv != null then
builtins.listToAttrs
(
builtins.map
(outputName: {
name = outputName;
value = drv.${outputName}.outPath;
})
drv.outputs
)
else null
) null;
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@flake.nix` around lines 91 - 111, The code dereferences
attrs.derivationAttrPath, attrs.derivation and fields on drv (drv.drvPath,
drv.outputs, drv.${outputName}.outPath) without guarding, which can throw and
make includingOutputPaths fail; fix by validating before access (e.g. use
builtins.hasAttr / builtins.tryEval or builtins.isDerivation where available) so
drv is only treated as a derivation when it actually has drvPath and outputs,
and when mapping outputs check each outputName exists on drv before reading
drv.${outputName}.outPath; update the branches that compute drv and the
derivation/outputs results to return null/nullable metadata when validation
fails instead of performing direct dereferences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant