diff options
| author | tv <tv@krebsco.de> | 2026-12-02 21:03:43 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-12-02 21:03:43 +0000 |
| commit | 2854de4ef2b45acee31a4362ff1adf52eb2d0c47 (patch) | |
| tree | 04435d2a9a55d7d434f60884b48cfc7224da7a8b /pkgs/rust/default.nix | |
| parent | a6be5efabb5398823115f1c823dbce64e9bfb906 (diff) | |
pkgs/rust: clean the packages' sources in the overlay
A package file in pkgs/rust names its source as it is; the overlay
builds a cleaned copy of it, and checks the plan against the source
itself. So the copy can leave Cargo.lock out next to a Cargo.json, as
before, while the lock check still has it. A source in the store
already, like a fetched one, isn't copied again.
Diffstat (limited to 'pkgs/rust/default.nix')
| -rw-r--r-- | pkgs/rust/default.nix | 17 |
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 |
