numtide / nix-filter

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

Make directories also match their descendants #27

Closed ilkecan closed 2 years ago

ilkecan commented 2 years ago

From an end user perspective this makes inDirectory redundant.

Closes: #25

ilkecan commented 2 years ago

With this, it is not possible to only include a directory without its contents. Maybe inDirectory could be redefined to be able to use it to only exclude entries while keeping the directory. Like:

  exclude-descendants-but-keep-the-directory = rec {
    root = ./fixture1;
    actual = nix-filter {
      inherit root;
      include = [
        "src/innerdir"
      ];
      exclude = [
        (nix-filter.inDirectory "src/innerdir")
      ];
    };
    expected = [
      "src"
      "src/innerdir"
    ];
  };
zimbatm commented 2 years ago

thanks!