Merge remote-tracking branch 'tweag/privateGithub' into flakes

This commit is contained in:
Eelco Dolstra 2019-04-16 12:23:56 +02:00
commit 3a5493bfe8
2 changed files with 7 additions and 2 deletions

View file

@ -226,13 +226,15 @@ static FlakeSourceInfo fetchFlake(EvalState & state, const FlakeRef flakeRef, bo
// FIXME: use regular /archive URLs instead? api.github.com
// might have stricter rate limits.
// FIXME: support passing auth tokens for private repos.
auto url = fmt("https://api.github.com/repos/%s/%s/tarball/%s",
refData->owner, refData->repo,
fRef.rev ? fRef.rev->to_string(Base16, false)
: fRef.ref ? *fRef.ref : "master");
std::string accessToken = settings.githubAccessToken.get();
if (accessToken != "")
url += "?access_token=" + accessToken;
auto result = getDownloader()->downloadCached(state.store, url, true, "source",
Hash(), nullptr, fRef.rev ? 1000000000 : settings.tarballTtl);

View file

@ -344,6 +344,9 @@ public:
Setting<Paths> pluginFiles{this, {}, "plugin-files",
"Plugins to dynamically load at nix initialization time."};
Setting<std::string> githubAccessToken{this, "", "github-acces-token",
"GitHub access token to get access to GitHub data through the GitHub API for github:<..> flakes."};
};