nixpkgs/pkgs/build-support/fetchgitlab/default.nix
Artturin 19d2bb4863 fetchFromGitLab: don't passthruAttrs fetchGit specific attrs to fetchUrl
if `fetchSubmodules = false` to 'fetchFromGitLab' then theres the
following error

error: anonymous function at /nix/store/9m8drnpifyl5qsx93g6ll2xw6wkps03z-source/pkgs/build-support/fetchurl/default.nix:41:1 called with unexpected argument 'fetchSubmodules'

       at /nix/store/9m8drnpifyl5qsx93g6ll2xw6wkps03z-source/pkgs/build-support/fetchzip/default.nix:36:1:

           35|
           36| fetchurl ((
             | ^
           37|   if (pname != "" && version != "") then
2022-10-29 19:12:07 +03:00

33 lines
1.2 KiB
Nix

{ fetchgit, fetchzip, lib }:
# gitlab example
{ owner, repo, rev, protocol ? "https", domain ? "gitlab.com", name ? "source", group ? null
, fetchSubmodules ? false, leaveDotGit ? false, deepClone ? false
, ... # For hash agility
} @ args:
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" "leaveDotGit" "deepClone" ];
useFetchGit = deepClone || fetchSubmodules || leaveDotGit;
fetcher = if useFetchGit then fetchgit else fetchzip;
gitRepoUrl = "${protocol}://${domain}/${slug}.git";
fetcherArgs = (if useFetchGit then {
inherit rev deepClone fetchSubmodules leaveDotGit;
url = gitRepoUrl;
} else {
url = "${protocol}://${domain}/api/v4/projects/${escapedSlug}/repository/archive.tar.gz?sha=${escapedRev}";
passthru = {
inherit gitRepoUrl;
};
}) // passthruAttrs // { inherit name; };
in
fetcher fetcherArgs // { meta.homepage = "${protocol}://${domain}/${slug}/"; inherit rev; }