Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ fetchgit, fetchzip, lib }: 2 3lib.makeOverridable ( 4# gitlab example 5{ owner, repo, rev, protocol ? "https", domain ? "gitlab.com", name ? "source", group ? null 6, fetchSubmodules ? false, leaveDotGit ? false, deepClone ? false 7, ... # For hash agility 8} @ args: 9 10let 11 slug = lib.concatStringsSep "/" ((lib.optional (group != null) group) ++ [ owner repo ]); 12 escapedSlug = lib.replaceStrings [ "." "/" ] [ "%2E" "%2F" ] slug; 13 escapedRev = lib.replaceStrings [ "+" "%" "/" ] [ "%2B" "%25" "%2F" ] rev; 14 passthruAttrs = removeAttrs args [ "protocol" "domain" "owner" "group" "repo" "rev" "fetchSubmodules" "leaveDotGit" "deepClone" ]; 15 16 useFetchGit = deepClone || fetchSubmodules || leaveDotGit; 17 fetcher = if useFetchGit then fetchgit else fetchzip; 18 19 gitRepoUrl = "${protocol}://${domain}/${slug}.git"; 20 21 fetcherArgs = (if useFetchGit then { 22 inherit rev deepClone fetchSubmodules leaveDotGit; 23 url = gitRepoUrl; 24 } else { 25 url = "${protocol}://${domain}/api/v4/projects/${escapedSlug}/repository/archive.tar.gz?sha=${escapedRev}"; 26 27 passthru = { 28 inherit gitRepoUrl; 29 }; 30 }) // passthruAttrs // { inherit name; }; 31in 32 33fetcher fetcherArgs // { meta.homepage = "${protocol}://${domain}/${slug}/"; inherit rev; } 34)