I've been trying to debug why nix-update does not work for spade in nixpkgs. The issue is that its use of fetchFromGitLab relies on fetchSubmodules, which in turn makes fetchFromGitLab use fetchgit with a .git url.
I've been playing around trying to solve this problem, and I now see three different solutions:
(1) implement a gitlab version fetcher for .git urls
(2) passthru the gitlab api url in fetchFromGitLab which is used instead of .url
(3) implement a generic version fetcher for .git urls (git ls-remote --tags --sort)
I've been trying to debug why
nix-update
does not work forspade
in nixpkgs. The issue is that its use offetchFromGitLab
relies onfetchSubmodules
, which in turn makesfetchFromGitLab
usefetchgit
with a.git
url.I've been playing around trying to solve this problem, and I now see three different solutions:
(1) implement a gitlab version fetcher for
.git
urls (2)passthru
the gitlab api url infetchFromGitLab
which is used instead of.url
(3) implement a generic version fetcher for.git
urls (git ls-remote --tags --sort
)Possible nix-update patch for (1)
```patch diff --git a/nix_update/version/__init__.py b/nix_update/version/__init__.py index 11dcb71..d567b12 100644 --- a/nix_update/version/__init__.py +++ b/nix_update/version/__init__.py @@ -9,7 +9,7 @@ from .bitbucket import fetch_bitbucket_snapshots, fetch_bitbucket_versions from .crate import fetch_crate_versions from .gitea import fetch_gitea_snapshots, fetch_gitea_versions from .github import fetch_github_snapshots, fetch_github_versions -from .gitlab import fetch_gitlab_snapshots, fetch_gitlab_versions +from .gitlab import fetch_gitlab_snapshots, fetch_gitlab_versions, fetch_gitlab_dotgit_versions from .npm import fetch_npm_versions from .pypi import fetch_pypi_versions from .rubygems import fetch_rubygem_versions @@ -42,6 +42,7 @@ fetchers: list[Callable[[ParseResult], list[Version]]] = [ fetch_sourcehut_versions, fetch_bitbucket_versions, # all entries below perform requests to check if the target url is of that type + fetch_gitlab_dotgit_versions, fetch_gitea_versions, ] diff --git a/nix_update/version/gitlab.py b/nix_update/version/gitlab.py index 2bc0703..b97d4b3 100644 --- a/nix_update/version/gitlab.py +++ b/nix_update/version/gitlab.py @@ -8,9 +8,27 @@ from ..errors import VersionError from ..utils import info from .version import Version +# found when fetchFromGitLab internally uses fetchzip GITLAB_API = re.compile( r"http(s)?://(?PPossible nixpkgs patch for (2)
```patch diff --git a/pkgs/build-support/fetchgit/default.nix b/pkgs/build-support/fetchgit/default.nix index 1b000fb49a99..00d59b8a61bd 100644 --- a/pkgs/build-support/fetchgit/default.nix +++ b/pkgs/build-support/fetchgit/default.nix @@ -28,6 +28,7 @@ lib.makeOverridable (lib.fetchers.withNormalizedHash { } ( , # Impure env vars (https://nixos.org/nix/manual/#sec-advanced-attributes) # needed for netrcPhase netrcImpureEnvVars ? [] +, passthru ? {} , meta ? {} , allowedRequisites ? null }: @@ -96,6 +97,6 @@ stdenvNoCC.mkDerivation { passthru = { gitRepoUrl = url; - }; + } // passthru; } )) diff --git a/pkgs/build-support/fetchgitlab/default.nix b/pkgs/build-support/fetchgitlab/default.nix index 749883f2365e..bad0fabc7e69 100644 --- a/pkgs/build-support/fetchgitlab/default.nix +++ b/pkgs/build-support/fetchgitlab/default.nix @@ -6,6 +6,7 @@ lib.makeOverridable ( , fetchSubmodules ? false, leaveDotGit ? false , deepClone ? false, forceFetchGit ? false , sparseCheckout ? [] +, passthru ? {} , ... # For hash agility } @ args: @@ -13,7 +14,9 @@ let slug = lib.concatStringsSep "/" ((lib.optional (group != null) group) ++ [ owner repo ]); escapedSlug = lib.replaceStrings [ "." "/" ] [ "%2E" "%2F" ] slug; escapedRev = lib.replaceStrings [ "+" "%" "/" ] [ "%2B" "%25" "%2F" ] rev; - passthruAttrs = removeAttrs args [ "protocol" "domain" "owner" "group" "repo" "rev" "fetchSubmodules" "forceFetchGit" "leaveDotGit" "deepClone" ]; + passthruAttrs = removeAttrs args [ "protocol" "domain" "owner" "group" "repo" "rev" "fetchSubmodules" "forceFetchGit" "leaveDotGit" "deepClone" "passthru" ]; + + gitlabApiUrl = "${protocol}://${domain}/api/v4/projects/${escapedSlug}"; useFetchGit = fetchSubmodules || leaveDotGit || deepClone || forceFetchGit || (sparseCheckout != []); fetcher = if useFetchGit then fetchgit else fetchzip; @@ -23,12 +26,16 @@ let fetcherArgs = (if useFetchGit then { inherit rev deepClone fetchSubmodules sparseCheckout leaveDotGit; url = gitRepoUrl; + + passthru = { + inherit gitlabApiUrl; + } // passthru; } else { - url = "${protocol}://${domain}/api/v4/projects/${escapedSlug}/repository/archive.tar.gz?sha=${escapedRev}"; + url = "${gitlabApiUrl}/repository/archive.tar.gz?sha=${escapedRev}"; passthru = { - inherit gitRepoUrl; - }; + inherit gitRepoUrl gitlabApiUrl; + } // passthru; }) // passthruAttrs // { inherit name; }; in ```Any preferences?