fetchFromGitHub from GHE rather than github

I’m trying to fetch a release from GHE, not github. fetchFromGitHub has worked in the past to fetch releases of public github repos, but not for GHE repos. fetchGit is not ideal because I don’t want to clone my repo, I just want the release.

You can set the githubBase attribute when calling fetchFromGitHub: https://github.com/NixOS/nixpkgs/blob/7e9437ceac3036e82ccd22481592c7adeed911e7/pkgs/build-support/fetchgithub/default.nix#L8

It seems to get blocked by authentication. It ends up fetching an HTML.

if i understand the logic correctly and what i know from my company GHE, a forceFetchGit = true may help. As fetchGithub tries to download with fetchzip, and that may fail (e.G. when a MFA is included on web login)

fetchGit essentially clones the repo right? I’m trying to avoid that because the building after fetchGit takes a long time to build, whereas fetching the release is much quicker.

I tried forceFetchGit, but it says “fatal: could not read Password for ‘https://*******’: No such device or address”. Any ideas?

If you need authenticated access to a git repo builtins.fetchGit is the right tool. Unlike the fetchers in nixpkgs, it’s able to use your user’s git and ssh configurations to fetch stuff. It’s not like a full clone; it tries to only fetch shallowly, so that it has to download as little as possible.

1 Like

What do you mean fetch shallowly?

For my particular use case, in our repo’s releases we expose a couple of tar.gzs. I want to just fetch those files, but I can’t figure a way to do that with fetchGit.

As you mentioned builds taking to long and releases…

  1. No variant of the Git or GH fetchers pulls Release files, only ever associated repo snapshots.
  2. You can’t just use pre-built binaries on NixOS unless you do some patching. Please read about binary packaging.
  3. Fetchurl or fetchtarball would be the correct things to use here, but you’ll still have an Auth problem

From man git-clone:

--depth <depth>

Create a shallow clone with a history truncated to the specified number of commits. Implies --single-branch unless --no-single-branch is given to fetch the histories near the tips of all branches. If you want to clone submodules shallowly, also pass --shallow-submodules.

Shallow just means it isn’t fetching the entire repo history; just the fraction of it necessary for a given number of revisions. builtins.fetchGit tries to use this to minimize how much is downloaded.

As @NobbZ said, git-based fetchers have no concept of the release tarballs you can publish to github. The custom ones in nixpkgs like fetchFromGitHub just get git trees, and usually know optimized URLs to download those from as opposed to doing an actual git clone.

1 Like