diff --git a/lib/fileset/default.nix b/lib/fileset/default.nix index e29f30251c690..9d631176198c0 100644 --- a/lib/fileset/default.nix +++ b/lib/fileset/default.nix @@ -668,6 +668,8 @@ in { - `name` (String): The name of the file + - `dir` (Path): The path of the directory containing the file. + - `type` (String, one of `"regular"`, `"symlink"` or `"unknown"`): The type of the file. This matches result of calling [`builtins.readFileType`](https://nixos.org/manual/nix/stable/language/builtins.html#builtins-readFileType) on the file's path. diff --git a/lib/fileset/internal.nix b/lib/fileset/internal.nix index 0d97ef1745683..50f4ccc869ffc 100644 --- a/lib/fileset/internal.nix +++ b/lib/fileset/internal.nix @@ -825,11 +825,11 @@ rec { _fileFilter = predicate: root: let # Check the predicate for a single file - # Type: String -> String -> filesetTree - fromFile = name: type: + # Type: Path -> String -> String -> filesetTree + fromFile = dir: name: type: if predicate { - inherit name type; + inherit dir name type; hasExt = ext: hasSuffix ".${ext}" name; # To ensure forwards compatibility with more arguments being added in the future, @@ -848,7 +848,7 @@ rec { if type == "directory" then fromDir (path + "/${name}") else - fromFile name type + fromFile path name type ) (readDir path); rootType = pathType root;