summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2021-03-28 21:49:20 +0200
committerRobert Hensing <robert@roberthensing.nl>2021-05-29 16:03:54 +0200
commit970273023a51020611dc915198f965d5dd34574a (patch)
treeeee500b558c206be01eebe6d5b29d2cfef152297 /lib
parentd14be76615299c55e8f239cd1ec95c8107f41b33 (diff)
downloadnixpkgs-970273023a51020611dc915198f965d5dd34574a.tar
nixpkgs-970273023a51020611dc915198f965d5dd34574a.tar.gz
nixpkgs-970273023a51020611dc915198f965d5dd34574a.tar.bz2
nixpkgs-970273023a51020611dc915198f965d5dd34574a.tar.lz
nixpkgs-970273023a51020611dc915198f965d5dd34574a.tar.xz
nixpkgs-970273023a51020611dc915198f965d5dd34574a.tar.zst
nixpkgs-970273023a51020611dc915198f965d5dd34574a.zip
lib.sources.sourceFilesBySuffices: Improve doc
Diffstat (limited to 'lib')
-rw-r--r--lib/sources.nix22
1 files changed, 17 insertions, 5 deletions
diff --git a/lib/sources.nix b/lib/sources.nix
index c7a0c000de6..407f9d21b8b 100644
--- a/lib/sources.nix
+++ b/lib/sources.nix
@@ -104,14 +104,26 @@ let
       inherit src;
     };
 
-  # Get all files ending with the specified suffices from the given
-  # directory or its descendants.  E.g. `sourceFilesBySuffices ./dir
-  # [".xml" ".c"]'.
-  sourceFilesBySuffices = path: exts:
+  /*
+    Get all files ending with the specified suffices from the given
+    source directory or its descendants, omitting files that do not match
+    any suffix. The result of the example below will include files like
+    `./dir/module.c` and `./dir/subdir/doc.xml` if present.
+
+    Type: sourceLike -> [String] -> Source
+
+    Example:
+      sourceFilesBySuffices ./. [ ".xml" ".c" ]
+  */
+  sourceFilesBySuffices =
+    # Path or source containing the files to be returned
+    src:
+    # A list of file suffix strings
+    exts:
     let filter = name: type:
       let base = baseNameOf (toString name);
       in type == "directory" || lib.any (ext: lib.hasSuffix ext base) exts;
-    in cleanSourceWith { inherit filter; src = path; };
+    in cleanSourceWith { inherit filter src; };
 
   pathIsGitRepo = path: (tryEval (commitIdFromGitRepo path)).success;