Merge pull request #5286 from ilkecan/add-a-warning-to-filterSource

Warn about the usage of filterSource with Nix store paths
This commit is contained in:
Eelco Dolstra 2021-10-06 21:02:39 +02:00 committed by GitHub
commit 53e4794289
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1923,6 +1923,19 @@ static RegisterPrimOp primop_filterSource({
.name = "__filterSource",
.args = {"e1", "e2"},
.doc = R"(
> **Warning**
>
> `filterSource` should not be used to filter store paths. Since
> `filterSource` uses the name of the input directory while naming
> the output directory, doing so will produce a directory name in
> the form of `<hash2>-<hash>-<name>`, where `<hash>-<name>` is
> the name of the input directory. Since `<hash>` depends on the
> unfiltered directory, the name of the output directory will
> indirectly depend on files that are filtered out by the
> function. This will trigger a rebuild even when a filtered out
> file is changed. Use `builtins.path` instead, which allows
> specifying the name of the output directory.
This function allows you to copy sources into the Nix store while
filtering certain files. For instance, suppose that you want to use
the directory `source-dir` as an input to a Nix expression, e.g.