summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/pure.nix11
-rw-r--r--pkgs/rust/default.nix13
2 files changed, 16 insertions, 8 deletions
diff --git a/lib/pure.nix b/lib/pure.nix
index 0d807404..68e11e53 100644
--- a/lib/pure.nix
+++ b/lib/pure.nix
@@ -23,6 +23,17 @@ let
else
toString x;
+ # A copy of src in the store, named name, without what is called one of
+ # removeNames, and without what filter rejects.
+ copyWithout = { name, src, removeNames, filter ? _: _: true }:
+ builtins.path {
+ inherit name;
+ path = src;
+ filter = path: type:
+ !builtins.elem (baseNameOf path) removeNames
+ && filter path type;
+ };
+
evalModulesConfig = modules: let
eval = evalModules {
inherit modules;
diff --git a/pkgs/rust/default.nix b/pkgs/rust/default.nix
index c26cf9de..da387670 100644
--- a/pkgs/rust/default.nix
+++ b/pkgs/rust/default.nix
@@ -92,15 +92,12 @@ in
# Copies a Cargo workspace into the store, leaving out what the build
# doesn't need.
- cleanCargoSource = name: src: builtins.path {
- inherit name;
- path = src;
+ cleanCargoSource = name: src: mylib.copyWithout {
+ inherit name src;
+ removeNames = [ ".git" ".graveyard" "target" ];
+ # Cargo.json is the resolved lock.
filter = path: type:
- !builtins.any lib.id [
- (type == "directory" && builtins.elem (baseNameOf path) [ ".git" ".graveyard" ])
- # Cargo.json is the resolved lock.
- (type == "regular" && baseNameOf path == "Cargo.lock" && builtins.pathExists (builtins.dirOf path + "/Cargo.json"))
- ];
+ !(type == "regular" && baseNameOf path == "Cargo.lock" && builtins.pathExists (builtins.dirOf path + "/Cargo.json"));
};
}