diff options
| author | tv <tv@krebsco.de> | 2026-12-02 15:15:33 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-12-02 15:44:42 +0000 |
| commit | 5bf8887ed1a14de5b3dc0c7406b5f0d5682c22d9 (patch) | |
| tree | 7db3066cb75981da3498f14acabd606b88533a7c | |
| parent | e48a64c9a2922074ed7f5d355a88f1daf3a32362 (diff) | |
pkgs/rust: leave target/ out of the copied source
A checkout in ~/sync/src with a cargo build in it was copied into the
store whole. The copying moves to mylib.copyWithout, which the Haskell
overlay can use, too.
| -rw-r--r-- | lib/pure.nix | 11 | ||||
| -rw-r--r-- | pkgs/rust/default.nix | 13 |
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")); }; } |
