-
Notifications
You must be signed in to change notification settings - Fork 17
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
Improve ergonomics for glob matching #9
Comments
Like in #8, the solution right now is pretty verbose:
|
I was expecting
...there is nothing in the When I try |
I assume from the docs that this maybe by design, but how might I support the recursive search for all Markdown files in a repository with
|
It's a limitation of the underlying nix builtin. I think the best strategy is to add isDirectory to the includes and blacklist the few folders that don't have md files in them. In theory, it's possible to achieve what you want, but it would require nix-filter to use two passes. With two additions to the /nix/store. |
Thanks for getting back to me. The README for this repo has helped me get up-to-speed on this problem, so thanks for taking the time to include that:
IdeaI'm thinking that maybe I could try an approach that uses
...into...
Which I could then maybe transform into |
Nice, I didn't think of that combo before. That would make things much more ergonomic. The only downside is more nix evaluation. |
This should work and works for me (tested with this and the latest commit). Are you using a somewhat recent version of the project? Also if you are only interested in including a pattern like src = nix-filter {
root = ~/zettelkasten;
include = with nix-filter; [
isDirectory
(matchExt "md")
];
} |
The issue is that |
I recently developed a safer and easier-to-use abstraction for source filtering in a PR to Nixpkgs, please take a look, try it out, and give feedback! https://discourse.nixos.org/t/easy-source-filtering-with-file-sets/29117 Particularly for this issue, it allows you to recursively specify files to include like this: let
fs = lib.fileset;
in
fs.unions [
# Only js files in the frontend directory
(fs.fileFilter (file: file.ext == "js") ./frontend)
] And this takes care of not including empty directories automatically. We can also easily define convenience functions like |
One thing I noticed when using this on a real-world project, is that
matchExt
is a bit too wide.What I mean is that typically I want to match under a specific folder. Eg:
frontend/**/*.js
. Not for the whole project. SomatchExt
doesn't scale really well with larger source bases.The text was updated successfully, but these errors were encountered: