summaryrefslogtreecommitdiffstats
path: root/pkgs/rust/lib
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-12-02 18:35:18 +0000
committertv <tv@krebsco.de>2026-12-02 18:35:18 +0000
commitfa757cafc99c50e310298d6aad6e4ef0bf27a699 (patch)
treee55f2353d719262e197cd749ecdeadbc51042f27 /pkgs/rust/lib
parent1b511421ff490ea7cf4831dfada5eca248da2cc4 (diff)
crate2nix-package: compare Git crates by revision, too
checkLock knew a crate by name and version only, so a plan with an older revision of a Git dependency of the same version passed: enstate's plan, with continuum's config crate at 45b0676 where Cargo.lock had 9f64a8d, failed to compile on the deploying host.
Diffstat (limited to 'pkgs/rust/lib')
-rw-r--r--pkgs/rust/lib/crate2nix-package.nix12
1 files changed, 10 insertions, 2 deletions
diff --git a/pkgs/rust/lib/crate2nix-package.nix b/pkgs/rust/lib/crate2nix-package.nix
index 0c867ee2..f37db6fb 100644
--- a/pkgs/rust/lib/crate2nix-package.nix
+++ b/pkgs/rust/lib/crate2nix-package.nix
@@ -126,11 +126,19 @@ let
checkLock = result:
let
id = name: version: "${name} ${version}";
+ # A crate from Git has its revision in both: "git+URL#REV" in the lock.
+ gitRev = lockSource: lib.last (lib.splitString "#" lockSource);
lockPackages = (builtins.fromTOML (builtins.readFile cargoLock)).package;
locked = builtins.listToAttrs (map
- (p: { name = id p.name p.version; value = null; })
+ (p: {
+ name = id p.name p.version
+ + lib.optionalString (lib.hasPrefix "git+" p.source) " ${gitRev p.source}";
+ value = null;
+ })
(builtins.filter (p: p ? source) lockPackages));
- planned = lib.mapAttrsToList (_: c: id c.crateName c.version)
+ planned = lib.mapAttrsToList
+ (_: c: id c.crateName c.version
+ + lib.optionalString (c.source.type or null == "git") " ${c.source.rev}")
(lib.filterAttrs (_: c: (c.source.type or "local") != "local")
plan.crates);
missing = builtins.filter (i: !(locked ? ${i})) planned;