diff --git a/pkgs/build-support/fetchgit/default.nix b/pkgs/build-support/fetchgit/default.nix index f2b4726fef09d..fd267fe34de8a 100644 --- a/pkgs/build-support/fetchgit/default.nix +++ b/pkgs/build-support/fetchgit/default.nix @@ -120,6 +120,7 @@ stdenvNoCC.mkDerivation { passthru = { gitRepoUrl = url; + inherit tag; }; } )) diff --git a/pkgs/build-support/fetchgithub/default.nix b/pkgs/build-support/fetchgithub/default.nix index ed24a6239449e..6d580b2e06566 100644 --- a/pkgs/build-support/fetchgithub/default.nix +++ b/pkgs/build-support/fetchgithub/default.nix @@ -59,12 +59,14 @@ let gitRepoUrl = "${baseUrl}.git"; + revWithTag = if tag != null then "refs/tags/${tag}" else rev; + fetcherArgs = (if useFetchGit then { inherit tag rev deepClone fetchSubmodules sparseCheckout fetchLFS; url = gitRepoUrl; } // lib.optionalAttrs (leaveDotGit != null) { inherit leaveDotGit; } else { - url = "${baseUrl}/archive/${if tag != null then "refs/tags/${tag}" else rev}.tar.gz"; + url = "${baseUrl}/archive/${revWithTag}.tar.gz"; passthru = { inherit gitRepoUrl; @@ -73,5 +75,5 @@ let ) // privateAttrs // passthruAttrs // { inherit name; }; in -fetcher fetcherArgs // { meta = newMeta; inherit rev owner repo tag; } +fetcher fetcherArgs // { meta = newMeta; inherit owner repo tag; rev = revWithTag; } ) diff --git a/pkgs/build-support/fetchgitlab/default.nix b/pkgs/build-support/fetchgitlab/default.nix index aef76270d5ec4..c060352d1a9fd 100644 --- a/pkgs/build-support/fetchgitlab/default.nix +++ b/pkgs/build-support/fetchgitlab/default.nix @@ -37,10 +37,9 @@ lib.makeOverridable ( repo ] ); + revWithTag = if tag != null then "refs/tags/" + tag else rev; escapedSlug = lib.replaceStrings [ "." "/" ] [ "%2E" "%2F" ] slug; - escapedRev = lib.replaceStrings [ "+" "%" "/" ] [ "%2B" "%25" "%2F" ] ( - if tag != null then "refs/tags/" + tag else rev - ); + escapedRevWithTag = lib.replaceStrings [ "+" "%" "/" ] [ "%2B" "%25" "%2F" ] revWithTag; passthruAttrs = removeAttrs args [ "protocol" "domain" @@ -77,7 +76,7 @@ lib.makeOverridable ( } else { - url = "${protocol}://${domain}/api/v4/projects/${escapedSlug}/repository/archive.tar.gz?sha=${escapedRev}"; + url = "${protocol}://${domain}/api/v4/projects/${escapedSlug}/repository/archive.tar.gz?sha=${escapedRevWithTag}"; passthru = { inherit gitRepoUrl; @@ -95,9 +94,9 @@ lib.makeOverridable ( meta.homepage = "${protocol}://${domain}/${slug}/"; inherit tag - rev owner repo ; + rev = revWithTag; } )