cleanSourceFilter
lib.sources.cleanSourceFilter
Docs pulled from | This Revision | 44 minutes ago
A basic filter for cleanSourceWith
that removes
directories of version control system, backup files (*~)
and some generated files.
Inputs
name
-
1. Function argument
type
-
2. Function argument
Noogle detected
Implementation
The following is the current implementation of this function.
cleanSourceFilter =
name: type:
let
baseName = baseNameOf (toString name);
in
!(
# Filter out version control software files/directories
(
baseName == ".git"
||
type == "directory"
&& (
baseName == ".svn"
|| baseName == "CVS"
|| baseName == ".hg"
|| baseName == ".jj"
|| baseName == ".pijul"
|| baseName == "_darcs"
)
)
||
# Filter out editor backup / swap files.
lib.hasSuffix "~" baseName
|| match "^\\.sw[a-z]$" baseName != null
|| match "^\\..*\\.sw[a-z]$" baseName != null
||
# Filter out generates files.
lib.hasSuffix ".o" baseName
|| lib.hasSuffix ".so" baseName
||
# Filter out nix-build result symlinks
(type == "symlink" && lib.hasPrefix "result" baseName)
||
# Filter out sockets and other types of files we can't have in the store.
(type == "unknown")
);