From 00b1ac5b234a59fdc6a8f5c7689d895d046d0952 Mon Sep 17 00:00:00 2001 From: Yureka Date: Fri, 10 Sep 2021 19:30:05 +0200 Subject: [PATCH] importCargoLock: git deps with rev, branch or tag Previously importCargoLog only recognized git dependencies with `rev =`. This adds support for git dependencies with `branch =` or `tag =`. --- pkgs/build-support/rust/import-cargo-lock.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkgs/build-support/rust/import-cargo-lock.nix b/pkgs/build-support/rust/import-cargo-lock.nix index 83f4e0df4f2d..3973aff398ab 100644 --- a/pkgs/build-support/rust/import-cargo-lock.nix +++ b/pkgs/build-support/rust/import-cargo-lock.nix @@ -12,14 +12,15 @@ let # Parse a git source into different components. parseGit = src: let - parts = builtins.match ''git\+([^?]+)(\?rev=(.*))?#(.*)?'' src; - rev = builtins.elemAt parts 2; + parts = builtins.match ''git\+([^?]+)(\?(rev|tag|branch)=(.*))?#(.*)'' src; + type = builtins.elemAt parts 2; # rev, tag or branch + value = builtins.elemAt parts 3; in if parts == null then null else { url = builtins.elemAt parts 0; - sha = builtins.elemAt parts 3; - } // lib.optionalAttrs (rev != null) { inherit rev; }; + sha = builtins.elemAt parts 4; + } // lib.optionalAttrs (type != null) { inherit type value; }; packages = (builtins.fromTOML (builtins.readFile lockFile)).package; @@ -137,7 +138,7 @@ let cat > $out/.cargo-config <