You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow performing shallow clones with builtins.fetchGit #4455
Is your feature request related to a problem? Please describe.
builtins.fetchGit provides no way to perform a shallow clone, which makes it much more space-efficient to clone large repositories (specifically nixpkgs) where you only want a specific revision.
Describe the solution you'd like
Add an option to builtins.fetchGit to specify the depth when fetching.
Describe alternatives you've considered
n/a
Additional context
n/a
Reacted by jaen, Johannes Spangenberg, Bjørn Forsman, Tim Cuthbertson, AleXoundOS, Antoine Viallon, Javier Honduvilla Coto and sharpchen
GitHub Actions even made --depth 1 the default.1 I think --depth 1 might be a sane default for Nix as well considering its field of application. I guess most builds don't want to look at previous commits. Anyway, I'm not that experienced with Nix yet, so I might be wrong. I assume making it the default would also cause problems with backward compatibility.
Method builtins.fetchTree builtins.fetchGit nixpkgs.fetchgit
Requires flakes enabled yes no no
Requires a hash no no yes (when pure)
Works with ssh agent (and remotes) yes yes no
So, sadly, there's no solution that ticks all the boxes. confused
Activity
JojOatXGME commentedon Jan 24, 2021
GitHub Actions even made
--depth 1the default.1 I think--depth 1might be a sane default for Nix as well considering its field of application. I guess most builds don't want to look at previous commits. Anyway, I'm not that experienced with Nix yet, so I might be wrong. I assume making it the default would also cause problems with backward compatibility.edolstra commentedon Jan 25, 2021
builtins.fetchTreesupports shallow fetches:yajo commentedon May 16, 2022
This matrix chat might be interesting for this problem.
Summarizing:
So, sadly, there's no solution that ticks all the boxes. 😕
Besides, this is very unexpected:
builtins.fetchTreeis available even when not enabled.aviallon commentedon May 23, 2022
The issue, also, is that it requires an experimental feature to be enabled... there doesn't seem to be any mid-term way to have shallow clones yet.
yajo commentedon May 24, 2022
Yes, and besides there's #5119. The shallow cloning feature in fetchTree really doesn't work.
ZoomRmc commentedon Aug 4, 2025
The issue is closed but it's not solved still.
ref: #9376 (unfortunately, drafted and stalled), #9402