Browse Source

Merge pull request #65083 from basvandijk/fix-composability-of-sourceByRegex

lib: allow sourceByRegex to be composed after cleanSourceWith
dhall-prelude
Eelco Dolstra 3 years ago committed by GitHub
parent
commit
4914a82186
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      lib/sources.nix

16
lib/sources.nix

@ -53,12 +53,16 @@ rec {
# Filter sources by a list of regular expressions.
#
# E.g. `src = sourceByRegex ./my-subproject [".*\.py$" "^database.sql$"]`
sourceByRegex = src: regexes: cleanSourceWith {
filter = (path: type:
let relPath = lib.removePrefix (toString src + "/") (toString path);
in lib.any (re: builtins.match re relPath != null) regexes);
inherit src;
};
sourceByRegex = src: regexes:
let
isFiltered = src ? _isLibCleanSourceWith;
origSrc = if isFiltered then src.origSrc else src;
in lib.cleanSourceWith {
filter = (path: type:
let relPath = lib.removePrefix (toString origSrc + "/") (toString path);
in lib.any (re: builtins.match re relPath != null) regexes);
inherit src;
};
# Get all files ending with the specified suffices from the given
# directory or its descendants. E.g. `sourceFilesBySuffices ./dir

Loading…
Cancel
Save