summaryrefslogtreecommitdiffstats
path: root/pkgs/rust/default.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-12-02 20:13:03 +0000
committertv <tv@krebsco.de>2026-12-02 20:13:03 +0000
commita6be5efabb5398823115f1c823dbce64e9bfb906 (patch)
treeeb76e4c0145b6725bea8334bc8f54041e5934ae0 /pkgs/rust/default.nix
parentfa757cafc99c50e310298d6aad6e4ef0bf27a699 (diff)
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/<pname>/ 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.
Diffstat (limited to 'pkgs/rust/default.nix')
-rw-r--r--pkgs/rust/default.nix19
1 files changed, 11 insertions, 8 deletions
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/<pname>/Cargo.json.
+ # A plan kept next to the package in hrm: pkgs/rust/<pname>/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