-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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.fileset.union
, lib.fileset.unions
: init
#255025
Conversation
We can now test returned paths being equal, no need to work around it anymore by making sure paths aren't returned (which would import them with the previous --json)
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/easy-source-filtering-with-file-sets/29117/11 |
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.
Noice
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.
Minor things and a concern about stack overflows when thunks build up in a lazy part despite foldl'
(might be due to incomplete understanding of filesets, but test would be appreciated)
@roberth @fricklerhandwerk Thanks! I applied the suggestions Good catch on the stack overflow potential @roberth, indeed it does stack overflow with many files! I fixed that now and included a test case with I also added a benchmark for I also opened two nixdoc issues: |
4e9e8c3
to
622cdf4
Compare
I'm fairly happy with this now, do you want to take a closer look @roberth? |
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.
Two suggestions, but lgtm now!
lib/fileset/default.nix
Outdated
# Annotate the elements with context, used by _coerceMany for better errors | ||
annotated = imap0 (i: el: { | ||
context = "element ${toString i}"; | ||
value = el; | ||
}) arg; | ||
|
||
filesets = _coerceMany "lib.fileset.unions" annotated; |
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.
These bindings are only used once. Are you sure the earlier renaming is necessary?
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.
Not necessary yeah, though just passing the argument between functions directly was a bit unsightly, so I'm using lib.pipe
instead now: https://github.com/NixOS/nixpkgs/compare/622cdf4567bc0e98a0926df7ea8ffedf89d94298..1498af4bf1ab058053ff35a4f601e02859420828
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.
I can never remember the order of pipe
, probably because I dislike it.
Whatever works, I guess.
lib/fileset/default.nix
Outdated
if ! isList arg then | ||
throw "lib.fileset.unions: Expected argument to be a list, but got a ${typeOf arg}." | ||
else if arg == [ ] then | ||
# TODO: This could be supported, but requires an extra internal representation for the empty file set |
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.
# TODO: This could be supported, but requires an extra internal representation for the empty file set | |
# TODO: This could be supported, but requires an extra internal representation for the empty file set, which would be special for not having a root. |
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.
Did s/root/base path
, since that's the term used throughout
622cdf4
to
1498af4
Compare
Also some minor formatting improvements
Previously a lot of processes were used, slowing it down considerably the more files were tested
$ ./benchmark.sh HEAD [...] Mean CPU time 0.04006 (σ = 0.0040146) for 10 runs is 8.193619775953792% (σ = 0.9584251052704821%) of the old value 0.488917 (σ = 0.0294955) [...]
Co-authored-by: Robert Hensing <[email protected]> Co-authored-by: Valentin Gagarin <[email protected]>
1498af4
to
94e103e
Compare
Very minor push to add a level of indentation to doc comments (diff) Thanks for the review Robert, I'll merge this when I see it next time with CI passing! |
Description of changes
This is another split off from the file set combinators PR, based on top of the already-merged
lib.fileset.toSource
and fileset infrastructure.This adds two new functions, allowing the creation of unions of file sets:
Comparatively, doing this correctly using the existing
lib.sources
functions is notoriously difficult.This work is sponsored by Antithesis ✨
Things done