summary refs log tree commit diff
path: root/lib/sources.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-10 13:28:21 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-10 13:28:21 +0200
commit5fef92c4a0c91153e3edac3a61a232581765074a (patch)
tree291d684d0ef71e200e6d8ab5c33fc1aca467cbb3 /lib/sources.nix
parent2a537fb369d1479748fe233261eaadfa5c2fa930 (diff)
downloadnixpkgs-5fef92c4a0c91153e3edac3a61a232581765074a.tar
nixpkgs-5fef92c4a0c91153e3edac3a61a232581765074a.tar.gz
nixpkgs-5fef92c4a0c91153e3edac3a61a232581765074a.tar.bz2
nixpkgs-5fef92c4a0c91153e3edac3a61a232581765074a.tar.lz
nixpkgs-5fef92c4a0c91153e3edac3a61a232581765074a.tar.xz
nixpkgs-5fef92c4a0c91153e3edac3a61a232581765074a.tar.zst
nixpkgs-5fef92c4a0c91153e3edac3a61a232581765074a.zip
Move pkgs/lib/ to lib/
Diffstat (limited to 'lib/sources.nix')
-rw-r--r--lib/sources.nix29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/sources.nix b/lib/sources.nix
new file mode 100644
index 00000000000..6f8554d340b
--- /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;
+
+
+}