-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
fileset.fileFilter
: Restrict second argument to paths
#267384
Conversation
fileset.fileFilter
: Restrict second argument to paths
c7ba94e
to
1f72f51
Compare
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.
Good idea, and I'm ok with the breaking change. It's for a good reason and low negative impact.
if path._type or "" == "fileset" then | ||
throw '' | ||
lib.fileset.fileFilter: Second argument is a file set, but it should be a path instead. | ||
If you need to filter files in a file set, use `intersection fileset (fileFilter pred ./.)` instead.'' |
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.
If you need to filter files in a file set, use `intersection fileset (fileFilter pred ./.)` instead.'' | |
If you need to filter files in a file set, use `intersection fileset (fileFilter pred ./.)` instead.'' |
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'd like to keep this for now because it's consistent with other error messages in the library.
While this change is backwards-incompatible, I think it's okay because: - The `fileFilter` function is not yet in a stable NixOS release, it was only merged about [a month ago](NixOS#257356). - All public uses of the function on GitHub only pass a path - Any `fileFilter pred fileset` can also be expressed as `intersection fileset (fileFilter pred path)` without loss of functionality. - This is furthermore pointed out in the new error message when a file set is passed
1f72f51
to
1c3eb9e
Compare
Just merged #267381 and rebased this PR on top |
Description of changes
Currently
fileFilter
has the typeThe predicate function currently supports properties
name
andtype
of the file. However, it might be really useful to allow filtering files by their path. But for the sake of reproducibility, we shouln't allow the absolute path. So instead it should be a subpath instead. But then the question is, what should it be relative to?So I propose to change the type signature of
fileFilter
toinstead, because it allows us to use the
Path
as the base for the subpath, allowing a future interface like this:While this change is backwards-incompatible, I think it's okay because:
fileFilter
function is not yet in a stable NixOS release, it was only merged about a month ago.fileFilter pred fileset
can also be expressed asintersection fileset (fileFilter pred path)
without loss of functionality.Ping @roberth @fricklerhandwerk
This work is sponsored by Antithesis ✨
Things done