-
-
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: refactor (v2) #361424
Conversation
@ofborg test installer |
|
|
Successfully built PS: ofBorg seems to have bailed out without completing the test (no error in the log, it just stops partway through), possibly due to a timeout or such? I had noticed the test was running very slowly (based on the live log output) |
@K900 I requested your review so you'd have a chance to confirm whether this cause issues with the installer, as I am unsure whether |
Ofborg's lib tests can help here. |
I already ran the lib tests locally (see PR checklist) but they didn't catch the issue in the previous PR either. |
You want to run |
Thanks for the pointer, and that passes too. |
@infinisil @K900, could one of you OK this (and potentially merge) ? This is blocking other work on |
"Blocker" generally refers to things that are blocking major changes, not feature additions. |
OK, then the label description should be updated to reflect that. |
@Gabriella439, as you reviewed the o.g. PR, would you be willing to review this? |
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.
Didn't have the chance to review this the first time, so here's a late one. Just minor things though, looking good overall :)
lib/filesystem.nix
Outdated
if pathIsRegularFile defaultPath then | ||
# if `${directory}/package.nix` exists, call it directly | ||
callPackage defaultPath {} | ||
else lib.concatMapAttrs (name: type: |
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.
else lib.concatMapAttrs (name: type: | |
else concatMapAttrs (name: type: |
And add concatMapAttrs
to the import list at the top. A bit annoying, but this is the standard to keep lib
more performant.
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.
That implies pretty silly things about the (C++) implementation, and seems like a very-premature optimization, especially considering that the filesystem access should be much slower
... but I'm not opposed to doing it either (as well as for lib.removeSuffix
) 😅
I was told it is better for eval performance: NixOS#361424 (comment)
@infinisil Thanks for catching those, and done! |
This is a second take on NixOS#359941, which was reverted by 940db57. Co-authored-by: Silvan Mosberger <[email protected]>
I was told it is better for eval performance: NixOS#361424 (comment)
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.
LGTM! Did you want to squash yourself? Feel free to merge yourself as you wish :)
inherit (lib) concatMapAttrs removeSuffix; | ||
inherit (lib.path) append; |
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.
Usually this would be added to the very top of this file, but after thinking about it, the performance benefit is also there if you do it here. In any case, that's a tiny detail and not worth nitpicking over further :)
Squashed |
6b8521e
to
065b480
Compare
Thanks again for the reviews, @infinisil <3 |
I was told it is better for eval performance: NixOS/nixpkgs#361424 (comment)
(packageDirectoryEntries path); | ||
inherit (lib) concatMapAttrs removeSuffix; | ||
inherit (lib.path) append; | ||
defaultPath = append directory "package.nix"; |
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.
Previously directory
could be a string but this forces it to be a path.
But I guess this change is heading in the right direction and users should adapt?
thought I could do append /. "string-dir"
and pass it as the directory, but it is not allowed either.
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.
Oof, good point, that wasn't an intended regression; if it was, at the very least it should be documented as such.
On the one hand, pushing for more-structured path handling makes sense. On the other, breaking an API present in stable releases (esp. in a relatively-subtle way) is not how I'd prefer to push that forward.
I'll shortly prepare a PR to fix this, thanks a lot for the report.
PS: “shortly” might take longer than expected, everything hurts today 😬
Second go at #359941
An assertion was too restrictive and broke the installer's tests, due to
directory
being a symlink.Things done
installer
nix-instantiate --eval --strict lib/tests/misc.nix
nix-build lib/tests/release.nix
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usageAdd a 👍 reaction to pull requests you find important.