Merge pull request #29815 from primeos/fetchFromGitHub

fetchFromGitHub: Always add meta.homepage to the derivation
This commit is contained in:
Orivej Desh 2017-09-29 21:59:42 +00:00 committed by GitHub
commit ccf2c06e38

View file

@ -198,19 +198,10 @@ with pkgs;
baseUrl = "https://${githubBase}/${owner}/${repo}"; baseUrl = "https://${githubBase}/${owner}/${repo}";
passthruAttrs = removeAttrs args [ "owner" "repo" "rev" "fetchSubmodules" "private" "githubBase" "varPrefix" ]; passthruAttrs = removeAttrs args [ "owner" "repo" "rev" "fetchSubmodules" "private" "githubBase" "varPrefix" ];
varBase = "NIX${if varPrefix == null then "" else "_${varPrefix}"}_GITHUB_PRIVATE_"; varBase = "NIX${if varPrefix == null then "" else "_${varPrefix}"}_GITHUB_PRIVATE_";
in if fetchSubmodules then
fetchgit ({
inherit name rev fetchSubmodules;
url = "${baseUrl}.git";
} // passthruAttrs)
else
# We prefer fetchzip in cases we don't need submodules as the hash # We prefer fetchzip in cases we don't need submodules as the hash
# is more stable in that case. # is more stable in that case.
fetchzip ({ fetcher = if fetchSubmodules then fetchgit else fetchzip;
inherit name; privateAttrs = lib.optionalAttrs private {
url = "${baseUrl}/archive/${rev}.tar.gz";
meta.homepage = "${baseUrl}/";
} // lib.optionalAttrs private {
netrcPhase = '' netrcPhase = ''
if [ -z "''$${varBase}USERNAME" -o -z "''$${varBase}PASSWORD" ]; then 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 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
@ -223,7 +214,12 @@ with pkgs;
EOF EOF
''; '';
netrcImpureEnvVars = [ "${varBase}USERNAME" "${varBase}PASSWORD" ]; netrcImpureEnvVars = [ "${varBase}USERNAME" "${varBase}PASSWORD" ];
} // passthruAttrs) // { inherit rev; }; };
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 = { fetchFromBitbucket = {
owner, repo, rev, name ? gitRepoToName repo rev, owner, repo, rev, name ? gitRepoToName repo rev,