fileset.fileFilter: Restrict second argument to paths#267384
Merged
roberth merged 1 commit intoNixOS:masterfrom Nov 15, 2023
Merged
fileset.fileFilter: Restrict second argument to paths#267384roberth merged 1 commit intoNixOS:masterfrom
fileset.fileFilter: Restrict second argument to paths#267384roberth merged 1 commit intoNixOS:masterfrom
Conversation
fileset.fileFilter: Restrict second argument to paths
c7ba94e to
1f72f51
Compare
roberth
reviewed
Nov 14, 2023
Member
roberth
left a comment
There was a problem hiding this comment.
Good idea, and I'm ok with the breaking change. It's for a good reason and low negative impact.
lib/fileset/default.nix
Outdated
Member
There was a problem hiding this comment.
Suggested change
| 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.'' |
Member
Author
There was a problem hiding this comment.
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
Member
Author
|
Just merged #267381 and rebased this PR on top |
fricklerhandwerk
approved these changes
Nov 15, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes
Currently
fileFilterhas the typeThe predicate function currently supports properties
nameandtypeof 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
fileFiltertoinstead, because it allows us to use the
Pathas the base for the subpath, allowing a future interface like this:While this change is backwards-incompatible, I think it's okay because:
fileFilterfunction is not yet in a stable NixOS release, it was only merged about a month ago.fileFilter pred filesetcan also be expressed asintersection fileset (fileFilter pred path)without loss of functionality.Ping @roberth @fricklerhandwerk
This work is sponsored by Antithesis ✨
Things done