A GitHub Archive Holds Nothing When .gitattributes Sets export-ignore
Why does a github: flake input (or any source tarball from GitHub) contain no files from a repo, and how do you fix and test it?
Definition
git archive, and the tarballs GitHub builds from it, skip every path marked export-ignore in .gitattributes. If a rule marks every path, the archive is nearly empty. A Nix flake input such as github:owner/repo downloads that archive, so it finds no flake.nix and fails.
How to spot it
- The flake error says
flake.nixdoes not exist, but the file is in the repo andgit cloneworks. - Download
https://github.com/<owner>/<repo>/archive/<rev>.tar.gzand list it. A few files meansexport-ignore. - Check with
git check-attr export-ignore -- flake.nix.
Fix
Remove the rule, or narrow it to the paths you want excluded. Push the fix, then test with --refresh, because Nix caches a branch ref for 1 hour.
Side effect
A GitHub archive has no .git, so any build step that runs git describe fails. Pass the version to the build another way. The Ardour flake writes libs/ardour/revision.cc in postPatch.
Worked example
The Ardour fork inherited an upstream .gitattributes with export-ignore on every path. The archive held only README-GITHUB.txt. Commit 6424021ed6 removed the file and github:diegobarrosaraya/ardour then resolved. See Merged State and Packaging.