diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-10-10 13:28:21 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-10-10 13:28:21 +0200 |
commit | 5fef92c4a0c91153e3edac3a61a232581765074a (patch) | |
tree | 291d684d0ef71e200e6d8ab5c33fc1aca467cbb3 /lib/sources.nix | |
parent | 2a537fb369d1479748fe233261eaadfa5c2fa930 (diff) |
Move pkgs/lib/ to lib/
Diffstat (limited to 'lib/sources.nix')
-rw-r--r-- | lib/sources.nix | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/sources.nix b/lib/sources.nix new file mode 100644 index 0000000000000..6f8554d340be3 --- /dev/null +++ b/lib/sources.nix @@ -0,0 +1,29 @@ +# Functions for copying sources to the Nix store. + +let lib = import ./default.nix; in + +rec { + + + # Bring in a path as a source, filtering out all Subversion and CVS + # directories, as well as backup files (*~). + cleanSource = + let filter = name: type: let baseName = baseNameOf (toString name); in ! ( + # Filter out Subversion and CVS directories. + (type == "directory" && (baseName == ".git" || baseName == ".svn" || baseName == "CVS")) || + # Filter out backup files. + (lib.hasSuffix "~" baseName) + ); + in src: builtins.filterSource filter src; + + + # Get all files ending with the specified suffices from the given + # directory. E.g. `sourceFilesBySuffices ./dir [".xml" ".c"]'. + sourceFilesBySuffices = path: exts: + let filter = name: type: + let base = baseNameOf (toString name); + in type != "directory" && lib.any (ext: lib.hasSuffix ext base) exts; + in builtins.filterSource filter path; + + +} |