From fa757cafc99c50e310298d6aad6e4ef0bf27a699 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 2 Dec 2026 18:35:18 +0000 Subject: 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. --- pkgs/rust/lib/crate2nix-package.nix | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'pkgs/rust/lib') 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; -- cgit v1.3.1