Skip to content

Commit

Permalink
fix: no rev found
Browse files Browse the repository at this point in the history
  • Loading branch information
yusdacra committed Apr 25, 2021
1 parent 4e922a0 commit 8f5f1e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 5 additions & 5 deletions build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ let
(
e:
let
key = if e ? rev then "rev=${e.rev}" else
if e ? tag then "tag=${e.tag}" else
if e ? branch then "branch=${e.branch}" else
throw "No 'rev', 'tag' or 'branch' specified";
key = if e ? rev then "?rev=${e.rev}" else
if e ? tag then "?tag=${e.tag}" else
if e ? branch then "?branch=${e.branch}" else
"";
in
{
name = "${e.url}?${key}";
name = "${e.url}${key}";
value = lib.filterAttrs (n: _: n == "rev" || n == "tag" || n == "branch") e // {
git = e.url;
replace-with = "nix-sources";
Expand Down
8 changes: 6 additions & 2 deletions lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ rec

extractRevision = source: lib.last (lib.splitString "#" source);
extractPart = part: source: if lib.hasInfix part source then lib.last (lib.splitString part (lib.head (lib.splitString "#" source))) else null;
extractRepoUrl = source: let splitted = lib.head (lib.splitString "?" source); in lib.substring 4 (lib.stringLength splitted) splitted;
extractRepoUrl = source:
let
splitted = lib.head (lib.splitString "?" source);
split = lib.substring 4 (lib.stringLength splitted) splitted;
in lib.head (lib.splitString "#" split);

parseLock = lock:
let
Expand All @@ -98,7 +102,7 @@ rec
packageLocks = builtins.map parseLock (lib.filter query cargolock.package);

mkFetch = lock: {
key = lock.revision or lock.rev or lock.tag or lock.branch
key = lock.rev or lock.tag or lock.branch or lock.revision
or (throw "No 'rev', 'tag' or 'branch' available to specify key, nor a git revision was found in Cargo.lock");
checkout = builtins.fetchGit ({
url = lock.url;
Expand Down

0 comments on commit 8f5f1e9

Please sign in to comment.