diff options
Diffstat (limited to 'pkgs/top-level/all-packages.nix')
-rw-r--r-- | pkgs/top-level/all-packages.nix | 81 |
1 files changed, 9 insertions, 72 deletions
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index efe9dbd2e62..da1f8a1533e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -261,78 +261,15 @@ in fetchCrate = callPackage ../build-support/rust/fetchcrate.nix { }; - fetchFromGitHub = { - owner, repo, rev, name ? "source", - fetchSubmodules ? false, private ? false, - githubBase ? "github.com", varPrefix ? null, - ... # For hash agility - }@args: assert private -> !fetchSubmodules; - let - baseUrl = "https://${githubBase}/${owner}/${repo}"; - passthruAttrs = removeAttrs args [ "owner" "repo" "rev" "fetchSubmodules" "private" "githubBase" "varPrefix" ]; - varBase = "NIX${if varPrefix == null then "" else "_${varPrefix}"}_GITHUB_PRIVATE_"; - # We prefer fetchzip in cases we don't need submodules as the hash - # is more stable in that case. - fetcher = if fetchSubmodules then fetchgit else fetchzip; - privateAttrs = lib.optionalAttrs private { - netrcPhase = '' - if [ -z "''$${varBase}USERNAME" -o -z "''$${varBase}PASSWORD" ]; then - echo "Error: Private fetchFromGitHub requires the nix building process (nix-daemon in multi user mode) to have the ${varBase}USERNAME and ${varBase}PASSWORD env vars set." >&2 - exit 1 - fi - cat > netrc <<EOF - machine ${githubBase} - login ''$${varBase}USERNAME - password ''$${varBase}PASSWORD - EOF - ''; - netrcImpureEnvVars = [ "${varBase}USERNAME" "${varBase}PASSWORD" ]; - }; - fetcherArgs = (if fetchSubmodules - then { inherit rev fetchSubmodules; url = "${baseUrl}.git"; } - else ({ url = "${baseUrl}/archive/${rev}.tar.gz"; } // privateAttrs) - ) // passthruAttrs // { inherit name; }; - in fetcher fetcherArgs // { meta.homepage = baseUrl; inherit rev; }; - - fetchFromBitbucket = { - owner, repo, rev, name ? "source", - ... # For hash agility - }@args: fetchzip ({ - inherit name; - url = "https://bitbucket.org/${owner}/${repo}/get/${rev}.tar.gz"; - meta.homepage = "https://bitbucket.org/${owner}/${repo}/"; - extraPostFetch = ''rm -f "$out"/.hg_archival.txt''; # impure file; see #12002 - } // removeAttrs args [ "owner" "repo" "rev" ]) // { inherit rev; }; - - # cgit example, snapshot support is optional in cgit - fetchFromSavannah = { - repo, rev, name ? "source", - ... # For hash agility - }@args: fetchzip ({ - inherit name; - url = "https://git.savannah.gnu.org/cgit/${repo}.git/snapshot/${repo}-${rev}.tar.gz"; - meta.homepage = "https://git.savannah.gnu.org/cgit/${repo}.git/"; - } // removeAttrs args [ "repo" "rev" ]) // { inherit rev; }; - - # gitlab example - fetchFromGitLab = { - owner, repo, rev, domain ? "gitlab.com", name ? "source", group ? null, - ... # For hash agility - }@args: fetchzip ({ - inherit name; - url = "https://${domain}/api/v4/projects/${lib.optionalString (group != null) "${lib.replaceStrings ["."] ["%2E"] group}%2F"}${lib.replaceStrings ["."] ["%2E"] owner}%2F${lib.replaceStrings ["."] ["%2E"] repo}/repository/archive.tar.gz?sha=${rev}"; - meta.homepage = "https://${domain}/${lib.optionalString (group != null) "${group}/"}${owner}/${repo}/"; - } // removeAttrs args [ "domain" "owner" "group" "repo" "rev" ]) // { inherit rev; }; - - # gitweb example, snapshot support is optional in gitweb - fetchFromRepoOrCz = { - repo, rev, name ? "source", - ... # For hash agility - }@args: fetchzip ({ - inherit name; - url = "https://repo.or.cz/${repo}.git/snapshot/${rev}.tar.gz"; - meta.homepage = "https://repo.or.cz/${repo}.git/"; - } // removeAttrs args [ "repo" "rev" ]) // { inherit rev; }; + fetchFromGitHub = callPackage ../build-support/fetchgithub {}; + + fetchFromBitbucket = callPackage ../build-support/fetchbitbucket {}; + + fetchFromSavannah = callPackage ../build-support/fetchsavannah {}; + + fetchFromGitLab = callPackage ../build-support/fetchgitlab {}; + + fetchFromRepoOrCz = callPackage ../build-support/fetchrepoorcz {}; fetchNuGet = callPackage ../build-support/fetchnuget { }; buildDotnetPackage = callPackage ../build-support/build-dotnet-package { }; |