about summary refs log tree commit diff
path: root/lib/fileset/internal.nix
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2023-11-24 00:15:43 +0100
committerGitHub <noreply@github.com>2023-11-24 00:15:43 +0100
commit7486aee82e46634dbe997ab4510cc54691a19bf5 (patch)
tree98576a1c80fcc3ac1d8da6e77714847cfaa875f9 /lib/fileset/internal.nix
parente03c9c3f1be4994c63b27ce60d41f13ebfeb3cad (diff)
parent6816f28c960c523e6a30f2ad4a1cc812251f5ffb (diff)
Merge pull request #266362 from tweag/fileset.fileFilter-ext
`lib.fileset.fileFilter`: Predicate attribute for file extension
Diffstat (limited to 'lib/fileset/internal.nix')
-rw-r--r--lib/fileset/internal.nix5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/fileset/internal.nix b/lib/fileset/internal.nix
index 2fddf0d022858..35d556e78391c 100644
--- a/lib/fileset/internal.nix
+++ b/lib/fileset/internal.nix
@@ -52,6 +52,7 @@ let
     concatStringsSep
     substring
     stringLength
+    hasSuffix
     ;
 
 in
@@ -797,9 +798,11 @@ rec {
         if
           predicate {
             inherit name type;
+            hasExt = ext: hasSuffix ".${ext}" name;
+
             # To ensure forwards compatibility with more arguments being added in the future,
             # adding an attribute which can't be deconstructed :)
-            "lib.fileset.fileFilter: The predicate function passed as the first argument must be able to handle extra attributes for future compatibility. If you're using `{ name, file }:`, use `{ name, file, ... }:` instead." = null;
+            "lib.fileset.fileFilter: The predicate function passed as the first argument must be able to handle extra attributes for future compatibility. If you're using `{ name, file, hasExt }:`, use `{ name, file, hasExt, ... }:` instead." = null;
           }
         then
           type