diff options
author | Yureka <yuka@yuka.dev> | 2021-09-10 19:30:05 +0200 |
---|---|---|
committer | Yureka <yuka@yuka.dev> | 2021-09-10 23:00:46 +0200 |
commit | 00b1ac5b234a59fdc6a8f5c7689d895d046d0952 (patch) | |
tree | f51b07da8ecfb0a0d6f1fdf3a25d919300d37929 /pkgs/build-support/rust/import-cargo-lock.nix | |
parent | 91a4081ce47b2c6309f26545d527804beb9f8e2c (diff) | |
download | nixpkgs-00b1ac5b234a59fdc6a8f5c7689d895d046d0952.tar nixpkgs-00b1ac5b234a59fdc6a8f5c7689d895d046d0952.tar.gz nixpkgs-00b1ac5b234a59fdc6a8f5c7689d895d046d0952.tar.bz2 nixpkgs-00b1ac5b234a59fdc6a8f5c7689d895d046d0952.tar.lz nixpkgs-00b1ac5b234a59fdc6a8f5c7689d895d046d0952.tar.xz nixpkgs-00b1ac5b234a59fdc6a8f5c7689d895d046d0952.tar.zst nixpkgs-00b1ac5b234a59fdc6a8f5c7689d895d046d0952.zip |
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 =`.
Diffstat (limited to 'pkgs/build-support/rust/import-cargo-lock.nix')
-rw-r--r-- | pkgs/build-support/rust/import-cargo-lock.nix | 11 |
1 files 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 83f4e0df4f2..3973aff398a 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 <<EOF [source."${gitParts.url}"] git = "${gitParts.url}" - ${lib.optionalString (gitParts ? rev) "rev = \"${gitParts.rev}\""} + ${lib.optionalString (gitParts ? type) "${gitParts.type} = \"${gitParts.value}\""} replace-with = "vendored-sources" EOF '' |