summaryrefslogtreecommitdiff
path: root/lib/fileset/README.md
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2023-11-14 07:42:59 +0100
committerSilvan Mosberger <silvan.mosberger@tweag.io>2023-11-15 01:20:36 +0100
commit1c3eb9eff1b864bf49c3661558b495235fc3b3b4 (patch)
tree8d72c4ef51a603588ec1c9dab6fde4a323369872 /lib/fileset/README.md
parentterraform-providers.baiducloud: 1.19.19 -> 1.19.20 (diff)
downloadnixpkgs-1c3eb9eff1b864bf49c3661558b495235fc3b3b4.tar.gz
lib.fileset.fileFilter: Restrict second argument to paths
While this change is backwards-incompatible, I think it's okay because: - The `fileFilter` function is not yet in a stable NixOS release, it was only merged about [a month ago](https://github.com/NixOS/nixpkgs/pull/257356). - All public uses of the function on GitHub only pass a path - Any `fileFilter pred fileset` can also be expressed as `intersection fileset (fileFilter pred path)` without loss of functionality. - This is furthermore pointed out in the new error message when a file set is passed
Diffstat (limited to 'lib/fileset/README.md')
-rw-r--r--lib/fileset/README.md15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/fileset/README.md b/lib/fileset/README.md
index 91f892a1be95..14b6877a9065 100644
--- a/lib/fileset/README.md
+++ b/lib/fileset/README.md
@@ -238,6 +238,21 @@ Arguments:
And it would be unclear how the library should behave if the one file wouldn't be added to the store:
`toSource { root = ./file.nix; fileset = <empty>; }` has no reasonable result because returing an empty store path wouldn't match the file type, and there's no way to have an empty file store path, whatever that would mean.
+### `fileFilter` takes a path
+
+The `fileFilter` function takes a path, and not a file set, as its second argument.
+
+- (-) Makes it harder to compose functions, since the file set type, the return value, can't be passed to the function itself like `fileFilter predicate fileset`
+ - (+) It's still possible to use `intersection` to filter on file sets: `intersection fileset (fileFilter predicate ./.)`
+ - (-) This does need an extra `./.` argument that's not obvious
+ - (+) This could always be `/.` or the project directory, `intersection` will make it lazy
+- (+) In the future this will allow `fileFilter` to support a predicate property like `subpath` and/or `components` in a reproducible way.
+ This wouldn't be possible if it took a file set, because file sets don't have a predictable absolute path.
+ - (-) What about the base path?
+ - (+) That can change depending on which files are included, so if it's used for `fileFilter`
+ it would change the `subpath`/`components` value depending on which files are included.
+- (+) If necessary, this restriction can be relaxed later, the opposite wouldn't be possible
+
## To update in the future
Here's a list of places in the library that need to be updated in the future: