From 8f5f1e9ce7b417a801420cb507aa07695e96984f Mon Sep 17 00:00:00 2001 From: Yusuf Bera Ertan Date: Sun, 25 Apr 2021 03:52:38 +0300 Subject: [PATCH] fix: no rev found --- build.nix | 10 +++++----- lib.nix | 8 ++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/build.nix b/build.nix index f8c6511..503bd84 100644 --- a/build.nix +++ b/build.nix @@ -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"; diff --git a/lib.nix b/lib.nix index 2ad0c78..e902f4e 100644 --- a/lib.nix +++ b/lib.nix @@ -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 @@ -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;