forked from mirrors/nixpkgs
all-packages: move fetch* to pkgs/build-support/
This commit is contained in:
parent
cb14f1404a
commit
d16e0f8dc3
10
pkgs/build-support/fetchbitbucket/default.nix
Normal file
10
pkgs/build-support/fetchbitbucket/default.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
{ fetchzip }:
|
||||
|
||||
{ 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; }
|
33
pkgs/build-support/fetchgithub/default.nix
Normal file
33
pkgs/build-support/fetchgithub/default.nix
Normal file
|
@ -0,0 +1,33 @@
|
|||
{ lib, fetchgit, fetchzip }:
|
||||
|
||||
{ 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; }
|
10
pkgs/build-support/fetchgitlab/default.nix
Normal file
10
pkgs/build-support/fetchgitlab/default.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
{ fetchzip, lib }:
|
||||
|
||||
# gitlab example
|
||||
{ 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; }
|
10
pkgs/build-support/fetchrepoorcz/default.nix
Normal file
10
pkgs/build-support/fetchrepoorcz/default.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
{ fetchzip }:
|
||||
|
||||
# gitweb example, snapshot support is optional in gitweb
|
||||
{ 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; }
|
10
pkgs/build-support/fetchsavannah/default.nix
Normal file
10
pkgs/build-support/fetchsavannah/default.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
{ fetchzip }:
|
||||
|
||||
# cgit example, snapshot support is optional in cgit
|
||||
{ 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; }
|
|
@ -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; };
|
||||
fetchFromGitHub = callPackage ../build-support/fetchgithub {};
|
||||
|
||||
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; };
|
||||
fetchFromBitbucket = callPackage ../build-support/fetchbitbucket {};
|
||||
|
||||
# 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; };
|
||||
fetchFromSavannah = callPackage ../build-support/fetchsavannah {};
|
||||
|
||||
# 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; };
|
||||
fetchFromGitLab = callPackage ../build-support/fetchgitlab {};
|
||||
|
||||
# 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; };
|
||||
fetchFromRepoOrCz = callPackage ../build-support/fetchrepoorcz {};
|
||||
|
||||
fetchNuGet = callPackage ../build-support/fetchnuget { };
|
||||
buildDotnetPackage = callPackage ../build-support/build-dotnet-package { };
|
||||
|
|
Loading…
Reference in a new issue