-
-
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.fileFilter
should allow filtering by file subpath/components
#269504
Comments
This would be the most powerful function, and users catch on to that. If the function can do anything, so can they. However, their sets will require more computation at evaluation time, and there's a good chance they'll be harder to read. Meanwhile, I haven't seen a concrete use case that needs such a function. Do you have a real world motivating use case for this? |
Indeed, I can't think of a good motivation for this right now. In fact I can only think of a reason why we shouldn't do this: People might try this: lib.fileset.fileFilter (file:
head file.components == ".git"
) ./. But that's really bad for performance. |
I do think we need something else for |
An alternative solution that is equally powerful is for the users to do some |
Not sure about pings tbh 😅. I feel like it's a nicely rounded library now, so I'm just say a lot of "do we really need this" and how about just this + that. |
Opened #269517 just to track the potential of a |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/easy-source-filtering-with-file-sets/29117/23 |
Issue description
Currently the predicate of
lib.fileset.fileFilter
only getsname
,type
(and soonhasExt
).There's no way to filter by the subpath/components of the file, something like this:
(
hasSuffix
currently also doesn't exist)Some ideas:
file.components :: [ String ]
: File components, always at least one element for the file's namefile.subpath :: String
: The file's subpathfile.dirComponents :: [ String ]
: Directory components, can be empty for files in the root levelfile.dirSubpath :: String
: Directory subpath, can be./.
for files in the root levelThis feature request is the motivation behind #267384.
This issue is sponsored by Antithesis ✨
The text was updated successfully, but these errors were encountered: