summaryrefslogtreecommitdiffstats
path: root/pkgs/rust/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/rust/default.nix')
-rw-r--r--pkgs/rust/default.nix17
1 files changed, 14 insertions, 3 deletions
diff --git a/pkgs/rust/default.nix b/pkgs/rust/default.nix
index 9d4f790d..318a6a9e 100644
--- a/pkgs/rust/default.nix
+++ b/pkgs/rust/default.nix
@@ -33,8 +33,8 @@ let
{ resolvedJson = path + "/Cargo.json"; };
# Checks the JSON plan against the checkout's Cargo.lock and Cargo.toml.
- # These come from dir, not src, because cleanCargoSource drops Cargo.lock
- # next to a Cargo.json.
+ # These come from the source itself, not its copy in the store, because
+ # cleanCargoSource leaves Cargo.lock out next to a Cargo.json.
planChecks = dir:
lib.optionalAttrs (builtins.pathExists (dir + "/Cargo.lock")) {
cargoLock = dir + "/Cargo.lock";
@@ -42,6 +42,13 @@ let
// lib.optionalAttrs (builtins.pathExists (dir + "/Cargo.toml")) {
cargoToml = dir + "/Cargo.toml";
};
+
+ # A source in the store already, like a fetched one, stays as it is:
+ # copying it would only make another one.
+ cleanSource = name: src:
+ if lib.isStorePath (toString src) then src
+ else self.cleanCargoSource name src;
+
in
{
@@ -100,8 +107,12 @@ in
lib.mapAttrs
(pname: path: let
args = callArgs path;
+ # The package file names the source as it is. A copy of it in the
+ # store gets built; the checks read the source itself, where
+ # Cargo.lock is even when the copy leaves it out.
+ src = cleanSource pname args.src;
in
- hrmPlan path args.src // args // planChecks args.src)
+ hrmPlan path src // args // { inherit src; } // planChecks args.src)
explicitPackages;
# Copies a Cargo workspace into the store, leaving out what the build