Skip to content
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

can this be composed with gitignore based filter? #17

Open
adrian-gierakowski opened this issue Feb 2, 2022 · 3 comments
Open

can this be composed with gitignore based filter? #17

adrian-gierakowski opened this issue Feb 2, 2022 · 3 comments

Comments

@adrian-gierakowski
Copy link

I'd like to have an explicit whitelist specified with nix-filter combined with a blacklist based on .gitignore. Can I compose nix-filter somehow with, for example: https://github.com/hercules-ci/gitignore.nix? Thanks!

@adrian-gierakowski
Copy link
Author

Bump

@zimbatm
Copy link
Member

zimbatm commented Aug 9, 2022

It would take a few days of work to assess and come up with a composable design properly. It's not something I planned to address, unless it comes up as a need in our consulting work.

@infinisil
Copy link

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

Along with basic combinators allowing you to add/remove files, it also comes with a lib.fileset.fromSource function, which can turn lib.source-based values, such as pkgs.nix-gitignore or gitignore.nix into a value that can be composed easily, like this:

let
  fs = lib.fileset;
in
# Remove all `./tests` files from non-gitignored files
fs.difference
  (fs.fromSource (gitignoreSource ./.))
  ./tests

This fixes the problem in this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants