mirror of
https://github.com/nix-community/naersk
synced 2024-11-10 14:14:14 +00:00
Parse lockfile for expanded revision
This commit is contained in:
parent
8ca2512256
commit
c55558b630
2 changed files with 10 additions and 2 deletions
|
@ -46,7 +46,7 @@ let
|
|||
let
|
||||
config = mkConfig arg;
|
||||
gitDependencies =
|
||||
libb.findGitDependencies { inherit (config) cargotomls; };
|
||||
libb.findGitDependencies { inherit (config) cargotomls cargolock; };
|
||||
in
|
||||
import ./build.nix
|
||||
(
|
||||
|
|
10
lib.nix
10
lib.nix
|
@ -76,6 +76,7 @@ rec
|
|||
# }
|
||||
findGitDependencies =
|
||||
{ cargotomls
|
||||
, cargolock
|
||||
}:
|
||||
let
|
||||
tomlDependencies = cargotoml:
|
||||
|
@ -92,7 +93,14 @@ rec
|
|||
checkout = builtins.fetchGit ({
|
||||
url = v.git;
|
||||
} // lib.optionalAttrs (v ? rev) {
|
||||
rev = v.rev;
|
||||
rev = let
|
||||
query = p: p.name == k && (lib.substring 0 (4 + lib.stringLength v.git) p.source) == "git+${v.git}";
|
||||
extractRevision = url: lib.last (lib.splitString "#" url);
|
||||
parseLock = lock: rec { inherit (lock) name source; revision = extractRevision source; };
|
||||
packageLocks = builtins.map parseLock (lib.filter query cargolock.package);
|
||||
match = lib.findFirst (p: lib.substring 0 7 p.revision == lib.substring 0 7 v.rev) null packageLocks;
|
||||
in
|
||||
if ! (isNull match) then match.revision else v.rev;
|
||||
} // lib.optionalAttrs (v ? branch) {
|
||||
ref = v.branch;
|
||||
} // lib.optionalAttrs (v ? tag) {
|
||||
|
|
Loading…
Reference in a new issue