From a6be5efabb5398823115f1c823dbce64e9bfb906 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 2 Dec 2026 20:13:03 +0000 Subject: pkgs/rust: a source's own plan, not the one kept in hrm A plan goes with the source it was made for. A checkout in ~/sync/src used the plan in pkgs/rust// anyway, which was made for the package's own source; now it uses its own Cargo.json, or none. A package's source that has a Cargo.json, like a checkout delivered by krops' checkouts=, uses that, too; the plan kept in hrm applies only to sources without one. --- pkgs/rust/default.nix | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'pkgs') diff --git a/pkgs/rust/default.nix b/pkgs/rust/default.nix index a557ccfd..9d4f790d 100644 --- a/pkgs/rust/default.nix +++ b/pkgs/rust/default.nix @@ -24,12 +24,13 @@ let # which crate2nix-package.nix would reject as unexpected arguments. callArgs = path: builtins.removeAttrs (self.callPackage path {}) [ "override" "overrideDerivation" ]; - # A plan kept next to the package in hrm: pkgs/rust//Cargo.json. + # A plan kept next to the package in hrm: pkgs/rust//Cargo.json, + # unless the package's source has a plan of its own, which then applies. # Settings in the package file itself take precedence. - hrmPlan = path: - lib.optionalAttrs (builtins.pathExists (path + "/Cargo.json")) { - resolvedJson = path + "/Cargo.json"; - }; + hrmPlan = path: src: + lib.optionalAttrs + (builtins.pathExists (path + "/Cargo.json") && !builtins.pathExists (src + "/Cargo.json")) + { 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 @@ -82,8 +83,10 @@ in src = self.cleanCargoSource pname dir; in if explicitPackages ? ${pname} then + # With the checkout's own plan, if any: the one kept in hrm is for + # the package's own source. assert mylib.debug "pkgs/rust: overriding ${pname}.src with ${mylib.pretty dir}"; - hrmPlan explicitPackages.${pname} // callArgs explicitPackages.${pname} // { inherit src; } // planChecks dir + callArgs explicitPackages.${pname} // { inherit src; } // planChecks dir else assert mylib.debug "pkgs/rust: automatic package ${pname} from ${mylib.pretty dir}"; { name = pname; inherit src; } // planChecks dir @@ -96,9 +99,9 @@ in rustHrmCrateArgs = lib.mapAttrs (pname: path: let - args = hrmPlan path // callArgs path; + args = callArgs path; in - args // planChecks args.src) + hrmPlan path args.src // args // planChecks args.src) explicitPackages; # Copies a Cargo workspace into the store, leaving out what the build -- cgit v1.3.1