can this be composed with gitignore based filter?
adrian-gierakowski opened this issue · comments
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!
Bump
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.
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!