From 6816f28c960c523e6a30f2ad4a1cc812251f5ffb Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Thu, 9 Nov 2023 01:29:38 +0100 Subject: lib.fileset.fileFilter: Predicate attribute for file extension --- lib/fileset/internal.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/fileset/internal.nix') diff --git a/lib/fileset/internal.nix b/lib/fileset/internal.nix index 23d7b847204c9..e2f4ba3ca3feb 100644 --- a/lib/fileset/internal.nix +++ b/lib/fileset/internal.nix @@ -52,6 +52,7 @@ let concatStringsSep substring stringLength + hasSuffix ; in @@ -796,9 +797,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 -- cgit 1.4.1