nix commands shouldn't cache remote git refs
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 17.7k
- Forks
- 2k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 80
Description
Describe the bug
In some situations, nix appears to cache the revision information for remote git repositories when it (arguably) shouldn't.
Steps To Reproduce
- Create a flake repository, push the initial commit.
- Run any of the following commands:
nix flake prefetch 'github:repo/name'nix flake metadata 'github:repo/name'nix build 'github:repo/name'nix run 'github:repo/name'
- Make some changes in the repository, commit and push them
- Run any of the commands in (2) again.
- Observe, that all the commands use the old commit revision instead of checking if the master HEAD was updated.
- Run these commands with
-vvvvand note the following lines:using cache entry '{"name":"source","type":"file","url":"https://api.github.com/repos/repo/name/commits/HEAD"}' -> '{"etag":"W/\"<redacted>\"","url":"https://api.github.com/repos/repo/name/commits/HEAD"}', '/nix/store/<redacted>-source' HEAD revision for 'https://api.github.com/repos/repo/name/commits/HEAD' is <old-commit-sha>
Expected behavior
nix commands should not cache the ref revision information.
nix-env --version output
nix-env (Nix) 2.8.1
P.S. This is not a GitHub-specific issue. The same problem happens with gitlab:repo/name and 'git+https://github.com/repo/name'.
P.P.S. Turns out, this is not HEAD or master specific either. github:repo/name?ref=other and git+https://github.com/repo/name?ref=other are also apparently cached.
P.P.P.S. The caching seems to expire on its own after some time which makes the current behaviour extra confusing.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the listed nix flake prefetch, metadata, build, and run commands, using -vvvv to inspect the remote Git cache entry. Trace how the HEAD or ref revision is resolved and cached; done means repeated commands check the current remote revision instead of using an expired-looking cached one.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, git
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100