-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib.packagesFromDirectoryRecursive: use explicit recursion, support nested scopes #359984
base: master
Are you sure you want to change the base?
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
1753d6d
to
4c6c2ec
Compare
Ran |
Rebased following the parent PR being merged |
4c6c2ec
to
8a5830c
Compare
I'd prefer to land #359898 first, as there will be a merge conflict over the function's documentation, and having the improved documentation will make documenting this PR's changes simpler. PS: Marked as draft again, since I'll wait for that to land before writing documentation in this PR. |
85b9516
to
ecca66e
Compare
Rebased atop both blocking PRs, added documentation. Still needs an example how to use |
This is only waiting for reviews, no functional change since the beginning of the month: only rebased to address the merge conflict and squash fixup commits, and moved the release notes entries. (One further change was tried and reverted, to be done in #369421) @9999years if you re-review, I think we could get that merged soonish |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice changes. Thank you for the efforts that you already put into it.
…pport nested scopes
…opes when `newScope` is provided
I'll hold off on rebasing (to address the merge conflict and squash fixup commits) until @hsjobeki can reply, to make the review work easier as it's possible to only display the new changes. |
This was implicit in the previous “other files are ignored.”
… the lambda also hoisted the default `recurseIntoDirectory`, as requested during review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Me and @hsjobeki reviewed this PR more closely together in a call and agreed on this feedback:
- The new
newScope
attribute argument and the removal of...
frompackagesFromDirectoryRecursive
looks good to us. - However, the
recurseIntoDirectory
concept feels a bit messy and hard to understand (we didn't quite get it in our ~1 hour of reviewing this PR together). In particular:- It's unclear what
processDir
does based on the documentation recurseArgs
has unclear motivation, is not tested and is missing example documentation.
- It's unclear what
In alignment with the one PR for each change lib
PR guideline, we think this PR should defer the recurseIntoDirectory
and recurseArgs
introduction to a separate PR that clearly states motivation for the new interfaces and adds missing docs with examples.
Also note that there's now separate Nixpkgs release notes where you need to note the lib
changes, which is the cause of the merge conflict.
Thanks for the review (again!) @hsjobeki & @infinisil !
Duly noted. FWIW, (I said “very inconvenient” because it's technically doable by changing
I'm somewhat confused there, since adding open recursion is part of how nested scopes are implemented (at least in this PR) but I can remove it from the public API and simplify as much as possible.
I'm aware. I simply haven't rebased yet, so it's easier to see which changes are introduced between reviews. |
The |
That's fair. In general I'm not keen on “hard-coding” behaviours like that without any way to pass a different one, but I guess it does cover the majority of usecases. Footnotes
|
@@ -310,3 +310,11 @@ | |||
- Structure of the `functor` of some types has changed. `functor` is an implementation detail and should not be relied upon. If you did rely on it let us know in this [PR](https://github.com/NixOS/nixpkgs/pull/363565). | |||
- [`lib.types.enum`](https://nixos.org/manual/nixos/unstable/#sec-option-types-basic): Previously the `functor.payload` was the list of enum values directly. Now it is an attribute set containing the values in the `values` attribute. | |||
- [`lib.types.separatedString`](https://nixos.org/manual/nixos/unstable/#sec-option-types-string): Previously the `functor.payload` was the seperator directly. Now it is an attribute set containing the seperator in the `sep` attribute. | |||
|
|||
- [`lib.packagesFromDirectoryRecursive`] now rejects unknown arguments, and applies [`lib.recurseIntoAttrs`] when recursing into a directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current code only applies recurseIntoAttrs
if makeScope
is passed. That seems like an oversight.
recurseIntoAttrs (makeScope newScope (self: | ||
# generate the attrset representing the directory, using the new scope's `callPackage` and `newScope` | ||
processDir (args // { | ||
inherit (self) callPackage newScope; | ||
}) | ||
)) | ||
else | ||
processDir args |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably makes sense to move recurseIntoAttrs
into processDir
to apply it unconditionally.
Follow-up on #359941
Extendlib.filesystem.packagesFromDirectoryRecursive
with support for explicit recursion.Add an example showing how to userecurseIntoDirectory
.packagesFromDirectoryRecursive
to create nested scopes for each (sub)directory (not just the top-level one) whennewScope
is given.Apply(Deferred to follow-up PR)recurseIntoAttrs
by default when recursing into a directory.packagesFromDirectoryRecursive
, ensuring:Things done
nix-instantiate --eval --strict lib/tests/misc.nix
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.