Conversation
E.g. Nixpkgs has a `nixosModules.readOnlyPkgs` like this: readOnlyPkgs = ./nixos/modules/misc/nixpkgs/read-only.nix;
📝 WalkthroughWalkthroughThe PR updates the flake schema by implementing path-aware module checking that conditionally imports modules based on type, and adds an Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
flake.nix (1)
111-145:⚠️ Potential issue | 🟠 MajorPropagate
isLegacyto the recursive nodes, not just the system wrapper.Line 113 marks only the top-level system entry. The package and intermediate nodes created on Lines 123-139 never get that flag, and
mkChildrenon Line 406 does not inherit parent metadata, so nestedlegacyPackagesentries still look non-legacy to consumers that inspect leaves.Proposed fix
builtins.mapAttrs ( attrName: attrs: # Necessary to deal with `AAAAAASomeThingsFailToEvaluate` etc. in Nixpkgs. self.lib.try ( if attrs.type or null == "derivation" then { + isLegacy = true; forSystems = [ attrs.system ]; shortDescription = attrs.meta.description or ""; derivationAttrPath = [ ]; what = "package"; } else # Recurse at the first and second levels, or if the # recurseForDerivations attribute if set. if attrs.recurseForDerivations or false then { + isLegacy = true; children = recurse (prefix + attrName + ".") attrs; } else { + isLegacy = true; what = "unknown"; } ) (throw "failed") ) attrs;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@flake.nix` around lines 111 - 145, The top-level isLegacy flag is only applied to the system wrapper but not to the recursive nodes produced by recurse, so update the objects returned inside recurse (the branches that produce the package node with what = "package", the branch that sets children, and the fallback branch that sets what = "unknown") to include isLegacy = true so that intermediate and leaf nodes inherit the legacy marker; modify the return objects inside the self.lib.try(...) block in the recurse function (used with builtins.mapAttrs on packagesForSystem and referenced by recurse and mkChildren) to add isLegacy = true to each created attrs object.
🤖 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 9-14: The current checkModule function does an import of module_
when builtins.isPath module_ is true, which can throw if the file is unreadable;
change the import to use builtins.tryEval so import-time errors are caught and
you then validate the resulting value's type (e.g., check the tryEval result for
success and then use builtins.isAttrs or builtins.isFunction on the evaluated
value). Update checkModule (and the local symbol module/module_) to use tryEval
when module_ is a path and treat failed tryEval as returning false rather than
letting the error propagate.
---
Outside diff comments:
In `@flake.nix`:
- Around line 111-145: The top-level isLegacy flag is only applied to the system
wrapper but not to the recursive nodes produced by recurse, so update the
objects returned inside recurse (the branches that produce the package node with
what = "package", the branch that sets children, and the fallback branch that
sets what = "unknown") to include isLegacy = true so that intermediate and leaf
nodes inherit the legacy marker; modify the return objects inside the
self.lib.try(...) block in the recurse function (used with builtins.mapAttrs on
packagesForSystem and referenced by recurse and mkChildren) to add isLegacy =
true to each created attrs object.
| let | ||
| module = if builtins.isPath module_ then import module_ else module_; | ||
| in | ||
| builtins.isAttrs module || builtins.isFunction module; |
There was a problem hiding this comment.
Do we have tests for this? If not, can we add some?
There was a problem hiding this comment.
Yeah we have a test (tests/legacyPackages).
isLegacyflake schema output attribute nix-src#381).nixosModules.readOnlyPkgslike this:Summary by CodeRabbit
Release Notes
New Features
Refactor