numtide / nix-filter

a small self-contained source filtering lib
MIT License
200 stars 17 forks source link

Provide an alias for `or` #8

Closed utdemir closed 3 years ago

utdemir commented 3 years ago

or, when used alone, seems to be a keyword. So, it's not possible to use the builtin or matcher inside a with statement:

  src = nix-filter {
    root = ./.;
    include = with nix-filter; [
      (and
        (or (inDirectory "src") (inDirectory "test"))
        (matchExt "hs"))
    ];
  };

fails with:

error: syntax error, unexpected OR_KW

Although there is a workaround of using nix-filter.or, it would be nice to provide an alias, so something like above is possible. The first name I'd reach in this case would probably be or_.

I do not know why this isn't the case with and.

zimbatm commented 3 years ago

Good call, thanks for trying this out!

zimbatm commented 3 years ago

All the directories have to explicitly be added, by the way, otherwise builtins.path won't recurse into them.

  nix-filter {
    root = ./.;
    include = with nix-filter; [
      (and
        (or_ (inDirectory "src") (inDirectory "test"))
        (or_ isDirectory (matchExt "hs")))
    ];
  }
utdemir commented 3 years ago

Thanks, I haven't thought of that! I'm looking forward to the issue you linked to have it more convenient.